I just wanted to try it out now. At present, there is no real practical purpose, but it's a bit of practice with git and python.
When a screen appears asking whether to restart services without asking, answer Yes.
apt-get install python-dev -y
We will make a directory to use, clone the files and folders with git, and make the python extension module for sha-3, which includes these four classes:
- sha3.sha224 - SHA-3 224 bits
- sha3.sha256 - SHA-3 256 bits
- sha3.sha384 - SHA-3 384 bits
- sha3.sha512 - SHA-3 512 bits
In Linux, in a Terminal window, execute these commands:
apt-get install python-dev cd mkdir sha3 cd sha3 git clone https://github.com/ajakubek/python-sha3.git cd python-sha3 python setup.py build python setup.py install
TroubleshootingIn May, 2014, a student could not perform the git clone because it asked for a password. The only solution we could find was to use a different machine.
If the "python setup.py build" fails, you may be missing some dependencies. This happened to a student who was using BT5 R1. To fix it, execute this command:
apt-get install python-crypto python-dev -y
Using the Modules in PythonIn Linux, in a Terminal window, execute these commands:This calculates the SHA-3 256 bit hash of an empty string, as shown below:
python from sha3 import sha256 s=sha256() s.update("") s.hexdigest()
But how can we know that is correct?
Here's the hash of an empty string, provided as a test case by the developers of SHA-3, from http://keccak.noekeon.org/files.html:
As you can see, the value is correct, starting with "c5d2"--it is working correctly!
Calculating the Hash of "abcd"In Linux, in a Terminal window, at the interactive Python prompt >>>, execute these commands:The result starts with "48bed", as shown below:
s=sha256() s.update("abcd") s.hexdigest()
Saving the Screen ImageMake sure the hash value starts with "48bed", as shown above.
Save a screen capture with a filename of "Proj 12xa from YOUR NAME".
Verifying the Hash AccuracyThe hash for "abcd" is included in the file "test.py" included in the git repository we cloned, as shown below:
As you can see, the string "abcd" hashes to a hash starting with "48bed", as expected.
The SHA-3 code is working.
Calculating the SHA-3 256-bit hash of "apple"Using the procedure above, calculate the 256-bit hash of "apple". The correct answer starts with "85dca".
To get credit you must send in the entire hash value--we'll check the end of it for accuracy. Save that as image "Proj 12xb from YOUR NAME"
Calculating the SHA-3 512-bit hash of "CCSF"Using the procedure above, calculate the 512-bit hash of "CCSF". The correct answer starts with "85f1".
To get credit you must send in the entire hash value--we'll check the end of it for accuracy. Save that as image "Proj 12xc from YOUR NAME"
Turning In Your Project
Email the images to email@example.com with a subject of "Project 12x from YOUR NAME".
Last modified: 12-9-14 12:24 pm