A Quick Introduction: Hashing

Gerald Nash ⚡️ on April 02, 2017

What is it? Hashing is a method of determining the equivalence of two chunks of data. A cryptographic hash function generates a unique s... [Read Full]
markdown guide
 

Just a quick point, but it's important. As the hash can't be 100% guaranteed to be unique (it's just highly likely to be unique) it can only be used to determine if something is different, not to see if two things are the same (although the typical mis-use is to compare for similarities). Given the hash space of Sha1, it's fairly unlikely there will be a hash collision, but not impossible (just look to the recent issues on WebKits SVN repository caused by hash collisions). Like I said, it's a small point, but an important one nonetheless.

 

Hashes are also used for passwords, which are the epitome of "hey, make sure that the hash is unique to only one password!"

It's important to know that there are special hash algorithms for passwords that are specifically made for shorter strings (rather than files), and take a relatively long time to compute (so that it's harder to brute-force them).

 

I would not recommend shadowing the built in hash function, as it may cause problems. I'd name the import crypt_hash, just to distinguish between the two. Other than that this is a good article! Simple and to the point as I like it :)

 
Hashing is a method of determining the equivalence of two chunks of data. 
A cryptographic hash function generates a unique string for any set of data. 

First two lines more mislead than explain, and as Ashley Sheridan pointed out they are not completely correct.

 

Why not just use shasum utility? I think it's available in all linux distros:

ayanami@frater260 ~ 18:23:25$ shasum /bin/bash
16b51b230deb932cd45cfc8667cac20dc33e7e40 /bin/bash

ayanami@frater260 ~ 18:24:57$ shasum -a 256 /bin/bash
f709c523ac22567a5e3efa914366ad723b56e98022d35bdc10a35e47a980d233 /bin/bash

ayanami@frater260 ~ 18:24:02$ shasum /bin/*
f27639cffe362e6c5e8d12aa30a9bc686f6a76e6 /bin/[
e2f1b0363e4e89c29a6c68f64342f1b8d7b3e147 /bin/arch
898bb82e4b45041ba5265ffceb0e499390c196cb /bin/ash
...

(by using -a we can specify which version of the sha we want computed - this way it's more portable than using sha256sum, sha512sum, etc)

 

Thought it was an article about Data Structures . Nice One . But try to write something more .

 
 
 
code of conduct - report abuse