跟讀練習: Password Storage Tier List: encryption, hashing, salting, bcrypt, and beyond - 通過影片學習英語口語

選擇練習模式

每種模式都會開啟全屏練習室。

130 句
如果句子過短或過長,請點選 Edit 進行調整。
1
If you're building a product that requires logging in, you probably have to deal with storing passwords.
2
But storing passwords opens you up to security risks, like someone breaking into your database, stealing all your passwords, and dealing immense reputational damage to your product.
3
So how do you store passwords in a secure fashion?
4
Let's start from the worst way, and steadily work our way up to something a little more secure.
5
I'm going to assume you have a little bit of software engineering knowledge.
6
Let's go.
7
The F tier way to store your passwords is like normal data.
8
a normal column perhaps with the rest of your user data.
9
Sometimes this is called storing passwords in plain text.
10
This is pretty bad because if a hacker gains access to your database, they can steal all the passwords effortlessly.
11
Security is all about multiple lines of defense, and storing passwords in plain text is not a defense.
12
If your database is breached, you're done, and database breaches happen quite often.
13
That's why this is F tier.
14
But how can we do better?
15
If you watched my encryption video, you might think that we should encrypt these passwords.
16
That's definitely an improvement, because if they break into your database, they get gibberish instead of useful information.
17
However, if they do get access to the key, then they can decrypt all the passwords, and you're unfortunately right back to F tier.
18
It's definitely nicer that the passwords aren't just sitting out there in the open, but if a hacker has access to your database already,
19
it may not be much more effort for them to steal the decryption key too from an adjacent server or config file.
20
So storing passwords in a way that makes it possible to retrieve the password increases the risk of an inside job,
21
where an employee with privileged access to the key decrypts people's passwords for nefarious purposes.
22
The Xword protection certainly helps, but this is D tier.
23
How do we get to C?
24
The key insight is that we only need to know
25
when the user types in the same password as when they signed up.
26
We don't actually need to know the password itself.
27
You might think the two are one and the same, but they actually aren't.
28
It's possible to take a password and generate a fingerprint from it, which will let us know if we encounter the same password in the future, but still be unable to recover the password directly from the fingerprint.
29
This is a technique known as hashing.
30
How do we use hashing?
31
When the user signs up, we take the password they provide, generate a small fingerprint or hash, and store it instead of the actual password.
32
In the future, when the user tries to log in, we take the password they typed in, we're the same hashing process and see if the output hashes compare.
33
If the hashes are the same, it's overwhelmingly likely that they typed in the correct password.
34
Thanks to the power of hashing, we're able to verify someone's password without storing the actual password.
35
Hashing might sound a little magical at the moment.
36
How does hashing prevent someone from recovering their original password from the output hash?
37
And how does it prevent two strings from hashing to the same thing
38
and allowing someone to log in with the wrong password?
39
For the first one, how to prevent someone from recovering their original password, the process of hashing involves a lot of aggressive mixing of the data in the original input to produce the output.
40
It's like taking three paints of different colors and mixing them together which probably results in some weird shade of brown.
41
With just the brown, you'd probably be unable to guess the original three colors that made the brown.
42
In the same way, you can't figure out the original password from the hash
43
because the bits in the data have all been thoroughly mixed and scrambled.
44
This property is known as being a one-way function, like a one-way street.
45
Once you hash, you can't unhash.
46
For the second, which is how hashing makes it hard for two strings to hash to the same value known as a hash collision, the answer is similar to what I just said.
47
That hash function mixes the data in such a way that even small tweaks in the input result in totally different hashes.
48
As a result, for good hash functions, there is no publicly known way to generate two strings whose hashes collide without just trying many many many strings.
49
No luck with these ten!
50
This property is called collision resistance.
51
Picking the right hash function is important.
52
We used to think that older hash functions that you may have heard about, like md5 and SHA-1 had collision resistance,
53
but cryptographic progress marches on and they've been proved insecure.
54
For example, about a decade ago, researchers published a method for generating a collision, two strings that have the same MD5 hash that you can run in about a second on your laptop.
55
So we've moved on to stronger hash functions like SHA-2, which is the one I've been using in this video.
56
With our new hashing technique under our belt, let's hash all the passwords in our database instead of encrypting them to arrive at C tier password storage.
57
Now, we don't have a key that effortlessly unlocks the password table like before, which is definitely an improvement.
58
However, we need to talk about dictionary attacks.
59
As it turns out, many people use extremely weak passwords like password or 123456.
60
If a hacker has access to your database, they can just run your hash function on password or 123456 to get the hash, and then find all the hashes that match in your database.
61
Voila, they've broken those people's passwords.
62
This is called a dictionary attack because you could run through the dictionary, hashing words as you go and seeing if any of them match the hash.
63
Remember that it's not possible to directly turn a hash back into a password, in general.
64
However, because the hacker knows the hash came from a password, they can use their knowledge of human nature to narrow down the possible guesses, which makes guessing feasible.
65
Furthermore, they can use lists of the most common passwords to pre-generate a huge database of hashes.
66
So all they need to do is to compare their huge database to your database to find matches.
67
These databases are known as rainbow tables.
68
How can we defend against this?
69
Let's go to B tier for a technique that protects against rainbow tables but not against dictionary attacks.
70
It's a technique called salting.
71
When the user signs up, rather than directly hashing each password, we can first generate a short random string called the salt.
72
Then we prepenn it to the string before running the hash.
73
We then store the salt next to the hashed password.
74
When the user logs in, we can prepenn the remembered salt to the password they entered and hash to see if it matches the stored password.
75
It's important to use the same salt at login that was generated during signup, which is why we want to store it in the database.
76
Otherwise the user wouldn't be able to log in even with the right password because the hashes wouldn't match.
77
This makes Rainbow Tables useless because their databases only contain non-salted hashes.
78
For example, these users have the password QWERTY but the table doesn't match anymore.
79
This has the added benefit of decorrelating users who have the same password.
80
Previously if two users used the same password their hashes would be the same, which is not ideal because you can see
81
that they have the same password even if you don't know what the password actually is.
82
Now, even though their passwords are the same, their salts are different, so the hashes are different.
83
But why is this still B-tier?
84
Remember the other issue we talked about, which is dictionary attacks.
85
An attacker with a list of common passwords can still try all of them against a hash using the salt.
86
They don't get the benefit of pre-computation, but they can still start from scratch.
87
Furthermore, specialized hardware like GPUs have made it possible for people to compute billions of hashes per second, which translates into billions of guesses per second.
88
How on earth do we stop this one?
89
Let's see what A-tier has to say.
90
An A-tier is using a specialized password hashing function that is deliberately slow.
91
The previous hash functions we discussed are designed to be fast because they're used for other applications besides passwords.
92
Password hashing functions like bcrypt, scrypt, and argon2 come with salting for free and more importantly are designed to be really really really slow,
93
to consume lots of power and to take lots of memory.
94
This sounds weird, but this is actually on purpose, to defend against the overwhelming power of hardware.
95
The billions of hashes per second we saw a moment ago can be slowed down to mere thousands per second, if not even slower, because you can actually choose the level of slowness you want.
96
This is known as the work factor.
97
With only thousands of guesses per second, that's still enough to easily go through the most common passwords, but it's not enough to break tougher or more obscure passwords.
98
With a high enough work factor, hackers might be able to break some of the passwords in your system, but not all of them.
99
After all, the goal of security is not to be immune to attacks which is impossible, but to hinder attackers enough that they turn their attention to other places.
100
As a concrete example, let's look at bcrypt.
101
The output of bcrypt looks like this.
102
It has a prefix that identifies the output as a bcrypted thing, a work factor, a 22 character salt, and a 31 character hash.
103
The most interesting thing about this is that the work factor is exponential.
104
When you increase the work factor by 1, the function becomes twice as slow.
105
Here's a graph of bcrypt hash time by work factor on my laptop.
106
The exponential increase is quite clear.
107
Most folks recommend setting it to around 15 for real use cases, which takes 1.3 seconds on my laptop.
108
Fun fact, when it was first published, the recommended work factor was just 6, which would take just 2 milliseconds on my modern laptop.
109
So is that it?
110
Are we done?
111
Is there an even higher tier?
112
S tier?
113
It's kind of a trick answer, but there is.
114
S tier is not storing passwords at all.
115
As we've learned in this video, storing passwords is quite tricky, so consider ways to avoid doing it at all.
116
For example, you can use other authentication services like sign in with Google
117
or sign in with Facebook and others so that users can log into your product using an established authentication platform.
118
Not only is it more convenient for users, you get to sleep better at night knowing that your system doesn't have any passwords at all in it.
119
That's all I have for today.
120
Let's recap.
121
First, we looked at storing passwords in plain text which means anyone can easily access them.
122
So we considered encrypting them, which is not ideal because their original form can still be recovered.
123
We introduced hashing to make that impossible, but we saw that people can pre-compute huge rainbow tables to quickly break passwords.
124
To counteract that, we introduced salting, which individualizes each password with a random string called the salt, so that pre-computed databases don't work anymore.
125
Unfortunately, hardware is so fast that even without pre-computed databases, attackers can still try billions of guesses per second,
126
so we need to switch to deliberately slow password hashing functions that greatly decrease the rate of guesses.
127
Finally, we bypassed the whole problem by considering how to not store passwords at all.
128
I hope this was helpful.
129
If you enjoyed this video, please consider sharing it with somebody else who might also enjoy it.
130
Thanks again!

下載應用

流利口語所需的一切

AI 發音評分逐句打分
音標練習掌握每個音
詞彙學習建立你的詞庫
詞彙遊戲邊玩邊學
FOR YOU

推薦影片

背景與背景

在網路安全領域,密碼儲存是一個至關重要的話題。隨著大家越來越重視資料安全,學習如何安全地儲存密碼變得尤為關鍵。本影片深入探討了密碼儲存的不同方式,從最基礎的明文儲存到更先進的雜湊技術,內容豐富且具有實用性。這段對話不僅涉及技術細節,也向我們傳達了在密碼管理方面的最佳實踐。

日常交流中的五個常用短語

  • 密碼儲存(password storage) - 描述如何儲存使用者密碼的方式。
  • 加密(encryption) - 用於保護資料的技術,使其在未授權使用者訪問時不可讀。
  • 雜湊(hashing) - 一種將密碼轉化為唯一指紋的技術,便於後續驗證而不洩露原密碼。
  • 內部人員風險(inside job risk) - 與員工接觸敏感資料相關的安全風險。
  • 衝突抵抗(collision resistance) - 確保不同輸入不會生成相同雜湊值的功能。

逐步影子跟隨指南

想要提高您的英語發音並在密碼儲存這一主題中熟練交流,可以利用影片中的內容進行練習。以下是一些步驟,幫助您更有效地進行英語口語練習:

  1. 觀看影片:首先反覆觀看影片,注意講者的語音語調和發音特點。
  2. 逐句複述:暫停影片,逐句模仿講者所說的內容。使用您自己的話表達同樣的意思,同時儘量符合原句的語調。
  3. 重點提煉:從影片中提取關鍵短語,重點練習發音,確保您的口音清晰可辨。
  4. 使用影子法:在觀看過程中,嘗試“影子跟隨”,即講者說完一段話後立刻跟著複述,使您的發音更加流利。
  5. 反覆練習:多次重複以上步驟,不斷糾正自己的發音,逐漸提高您的交流能力。

通過這些方法,您可以在日常交流中更加自信。利用這樣的影子跟隨法,不僅能提高英語發音,還能幫助您在與技術和安全相關的話題中游刃有餘。記得常來觀看與技術相關的YouTube影片,結合看YouTube學英語的方法進行練習,將大大提高您的英語口語練習成果。

影片中的語法

說話人最常用的結構,並附上影片中的原話:

結構影片中的用法
被動語態 be + 過去分詞 — 強調發生了什麼,而不是誰做的is called · is breached · is known
定語從句 who / which + 從句 — 補充說明人或事物second, which is · before, which is · guesses, which makes
現在完成時 have/has + 過去分詞 — 過去發生但與現在仍有關聯的事they've been proved · we've moved · they've broken

什麼是跟讀法?

跟讀法 (Shadowing) 是一種有科學依據的語言學習技巧,最初開發用於專業口譯員的培訓,並由多語言者Alexander Arguelles博士普及。這個方法簡單而強大:您在聽英語母語原聲的同時立即大聲重複——就像是一個延遲1-2秒緊跟說話者的影子。與被動聽力或語法練習不同,跟讀法強迫您的大腦和口腔肌肉同時處理並模模擬實的講話模式。研究表明它能顯著提高發音準確性,語調,節奏,連讀,聽力理解和口語流利度——使其成為雅思口語備考和真實英語交流最有效的方法之一。

影子跟讀法: 閱讀完整分步指南 →