Video Coming Soon...
49: sha2sum
WARNING: This is from the Go course but I'm rewriting the code and the description to fit C. If you want to attempt it go ahead. The challenge is the same, just no examples yet.
There's many different hashing utilities, but they all do the same thing: convert a gigantic number to a smaller number using cryptographic primitives. The one you'll use is called sha512 and Go provides very good cryptography support in the standard library.
The way a tool like sh2sum works is this:
- It opens a file and reads in the bytes.
- Each byte is also a number, so it can feed that byte to a cryptographic function.
- This function's design allows it to input many, many numbers but only output one large number. In our case, a 512 bit number.
- These functions are required to have "no collisions," which means if you feed them even slightly different inputs you should get totally different results.
- This lets you
sha2suma file to confirm that you received the right one, that it wasn't corrupted, and to just know if two files are actually different.
Register for From Impostor to Programmer
Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.