Grokking Algorithms



Download 6,4 Mb.
Pdf ko'rish
bet104/120
Sana21.12.2022
Hajmi6,4 Mb.
#893167
1   ...   100   101   102   103   104   105   106   107   ...   120
Bog'liq
Grokking Algorithms An Illustrated Guide for Programmers and Other

The SHA algorithms
Do you remember hashing from chapter 5? Just to recap, suppose you 
have a key, and you want to put the associated value in an array.
You use a hash function to tell you what slot to put the value in.
And you put the value in that slot.


214
Chapter 11
 
 
I
 
 
Where to go next
his allows you to do constant-time lookups. When you want to know 
the value for a key, you can use the hash function again, and it will tell 
you in O(1) time what slot to check. 
In this case, you want the hash function to give you a good distribution. 
So a hash function takes a string and gives you back the slot number for 
that string. 
Comparing iles
Another hash function is a secure hash algorithm (SHA) function. 
Given a string, SHA gives you a hash for that string.
he terminology can be a little confusing here. SHA is a 
hash function

It generates a 
hash
, which is just a short string. he hash function for 
hash tables went from string to array index, whereas SHA goes from 
string to string. 
SHA generates a diferent hash for every string.
Note
SHA hashes are long. They’ve been truncated here.
You can use SHA to tell whether two iles are the same. his is useful 
when you have very large iles. Suppose you have a 4 GB ile. You want 
to check whether your friend has the same large ile. You don’t have to 
try to email them your large ile. Instead, you can both calculate the 
SHA hash and compare it.


215
The SHA algorithms
Checking passwords
SHA is also useful when you want to compare strings without revealing 
what the original string was. For example, suppose Gmail gets hacked
and the attacker steals all the passwords! Is your password out in the 
open? No, it isn’t. Google doesn’t store the original password, only the 
SHA hash of the password! When you type in your password, Google 
hashes it and checks it against the hash in its database.
So it’s only comparing hashes—it doesn’t have to store your password! 
SHA is used very commonly to hash passwords like this. It’s a one-way 
hash. You can get the hash of a string.


216

Download 6,4 Mb.

Do'stlaringiz bilan baham:
1   ...   100   101   102   103   104   105   106   107   ...   120




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish