How Websites Check Your Password

栏目: IT技术 · 发布时间: 4年前

内容简介:Ever wondered how websites check your password? I mean, how can they check your password without being able to read your password? It’s a catch 22, surely?So you login to one of your many online accounts, you enter your credentials, the website checks your

Ever wondered how websites check your password? I mean, how can they check your password without being able to read your password? It’s a catch 22, surely?

So you login to one of your many online accounts, you enter your credentials, the website checks your details and logs you in. But how websites check your password is a bit of a mystery, right?

In this post I’ll take you through how websites check your password so you can login, yet still keep them secure.

Sites like Have I Been Pwned regularly detail password dumps from compromised websites. These dumps can contain both plaintext or hashed passwords. But what does that mean?

Plaintext Passwords

Plaintext passwords are passwords that are not obfuscated in anyway. So the text you read is the actual password. Let’s say my password was Password123 (it isn’t, because that’s acrap password) and it was stored in plaintext, then anyone would be able to see that my password was Password123 .

This is obviously extremely insecure as anyone who has access to where my password is stored can read it, and potentially re-use it.

Hashed Passwords

Hashing is often confused with encryption, but there is a significant difference between the two. Hashing is a one-way mathematical algorithm that cannot be reversed. Encryption can be reversed via decryption.

When something is hashed, the output is always the same size. So if I was to use the MD5 algorithm to hash Password123 , or an entire book, the resulting hash would always be 32 characters long.

This is because hashing uses a mathematical algorithm to create a fixed output from a variable source string of text. You can see the MD5 hash for both Password123 and the entire Hamlet play below.

42f749ade7f9e195bf475f37a44cafcb
e4b74bb9f1b22e373d7e0c9cbe1672b1

As you can see, both hashes are 32 characters long. Despite Password123 being 11 characters long and Hamlet being approximately 200,000 characters in length.

Because the hashes are mathematically created, the output will always be the same value. However, if the input string changes even slightly, the resulting hash is completely different. For example, below is the MD5 hash for Password123 (notice the space on the end):

b43105d6f779dfb2e13cdb1a2667a6be

As you can see, just adding a space to the end of the input string completely changes the hashed output.

How Websites Check Your Password

So now you have an understanding of the basics of hashing, let’s look at how hashing it used to check your password when you log in.

When you sign up for an account with a website, a hashed version of your password will be stored within their user database. When you subsequently try to login to your account, the string you enter into the password field is hashed in the same way as when you signed up, and the results are compared to the hashed password they have within their database.

If the resulting hashes match, you’re allowed to login. If they don’t, you’re not. It’s that simple. That’s basically how websites check your password without actually knowing your password. Clever, huh?

How Websites Check Your Password

Conclusion

Now you know how websites check your password, so the next time you log into a site, you have an idea of what it’s doing with your credentials.

This post doesn’t cover all aspects of password security – it is just an intro. Things like hash collisions , and therefore more secure algorithms, aren’t covered. Neither is salting . This is a deliberate decision to help people who are new to hashing grasp the concept.

I may write a follow up post in the future, but in the meantime, please don’t email me saying that I didn’t cover collisions or salting. I know I didn’t and it was a deliberate omission.


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

商战

商战

杰克•特劳特、阿尔•里斯 / 李正栓、李腾 / 机械工业出版社 / 2011-3 / 42.00元

本书重点阐述了商战中的四种常用战略形式,如防御战、进攻战、侧翼战和游击战,针对每一种形式又提出了三条应遵循的原则,以及如何在具体的商战中应用这些原则。本书分析了商战中的实际案例:可口可乐与百事可乐的战役,汉堡王与温迪斯对麦当劳的挑战以及DEC对阵IBM等。这些人们熟知品牌的案例在作者精心的组织下,使读者不仅加深了对本书中心思想的理解,而且学习了如何在实战中具体应用各种营销战略和策略的技巧。 ......一起来看看 《商战》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码