what is hashing and when do you use it

699 views

Its different then regular encryption right?

In: Technology

5 Answers

Anonymous 0 Comments

A hash function just takes an input and sorts it into one of several boxes. It picks the box arbitrarily but it should pick the same box for the same input. And ideally you want exactly 1 input per box having more is called a “hash collision”.

So to minimize the chance of hash collisions without making the hash function complex and/or predictable you just increase the number of boxes. Idk 256 bit would be 2²⁵⁶ so as we know that 2¹⁰ = 1024 ~ 10³ we and as adding exponents means multiplying them with the base we could also write that as 2²⁵⁰*2⁶ = (2¹⁰)²⁵ *2⁶ = (10³)²⁵ *2⁶ = 10⁷⁵*2⁶ = 64*10⁷⁵ = 6.4*10⁷⁶

So savely more options than atoms in the universe even if you divide it by the ~ 65000 symbols in the unicode.

Though while 256 bits are a lot of options it’s not a lot of information 256 yes or no questions where you have to send the questions separately, that’s not much. So in terms of encryption it’s not all that useful as you’d maybe need to write a novel as input to receive a short string of 256 ones and zeros as output. The other way around would be more useful.

Provide something like a password or phrase and get access to a whole novel. And there you have symmetric and asymmetric encryption method. So without going into too much detail, symmetric encryption uses the same key for encryption and decryption. So think of a safe, you open it deposit stuff and close it. The key to open (decrypt) and to close (encrypt) is the same, it’s symmetric. Asymmetric encryption on the other hand is more like locked mail boxes. Where you have a public key (your mail box) and a private key (the key to your mailbox). So encryption is people throwing their mail in your mail box. After which neither they nor anybody else can reach it which opening the box. While decryption is using your key to open the mail box and taking out the mail.

That way encryption and decryption use different keys, asymmetric. This is useful if you have to send keys over insecure channels because here the public key can very much be public, it doesn’t matter if people know where your mailbox is unless they have the key to open it (assuming it’s otherwise unbreakable).

But back to hashes. They are only moderately useful to encrypt information but you can encrypt passwords quite neatly and store them somewhere without giving it away to the person storing it. You just enter it into a hash function and store the hash. If you use it again, it will match with the hash in the database if not, then it was wrong. So if the passwords are stolen that information will be next to useless. And if you want to go a step further you can “salt” the hash, that is add some random noise to the password so that even if it is broken it’s still not your password but your password + noise.

You are viewing 1 out of 5 answers, click here to view all answers.