C programs must compile with no warnings or errors using: gcc -std=c11 -pedantic -Wall
Each source file must start with a comment containing your name and a description.
Write a C program using SHA1() to create a hash which starts with "ECE8473..." when viewed in hex.
The hash input must be a printable string consisting of your userid followed by "/" followed by 8 hex digits representing a 32-bit unsigned integer nonce.
Mining consists of finding a nonce that produces the desired hash.
The program output should not be excessive (don't show all 4 billion possible hashes)
and the final output must show the data string and hash so that the result can be confirmed
using openssl sha1
or
sha1sum
.
Include the program output in a comment at the bottom of the source code.
Example which prints the first 5 iterations and the final values:
$ ./p1 rperry/00000000 8EB620387C3AB73E47464113DC99D7134501FEB6 rperry/00000001 6AC41D5EE1EB3DAC3209D9C66DAB426B3524127E rperry/00000002 7D986738998DFC8D7D4F30A082A2C523043E5FE6 rperry/00000003 61AD80A4E71E6259AA8A1E2551A330CFC33D01A2 rperry/00000004 DE0E8C936DCEDF6129357FF1CD1861E525E83965 rperry/08a2736b ECE8473CE652204FB2529F63E17AA1DB27DC661F $ echo -n "rperry/08a2736b" | openssl sha1 (stdin)= ece8473ce652204fb2529f63e17aa1db27dc661f
References: sha1.c (SHA1 example), Makefile, SHA1(), sprintf(), BADA55 Crypto