SHA256 using OpenSSL library (Linux)

I love cryptography and it was one of my favorite subjects in college. So recently when at work, I was asked to compute SHA256 for some data, I did some reading and learnt a lot of new stuff. I love learning anything new so enjoyed this exercise a lot. One of those days when work can be actually fun!

“A cryptographic hash (sometimes called ‘digest’) is a kind of ‘signature’ for a text or a data file. SHA-256 generates an almost-unique 256-bit (32-byte) signature for a text. A hash is not ‘encryption’ – it cannot be decrypted back to the original text (it is a ‘one-way’ cryptographic function, and is a fixed size for any size of source text). This makes it suitable when it is appropriate to compare ‘hashed’ versions of texts, as opposed to decrypting the text to obtain the original version. Such applications include stored passwords, challenge handshake authentication, and digital signatures.” (taken from here).

Continue reading