Need help with this using the pycrypto library in python 27
Need help with this, using the pycrypto library in python 2.7:
This homework is designed to practice with hash functions.The files for this homework is at http://www.cs.fsu.edu/~zzhang/CIS4360_Fall_2016_files/HW2files.zip
In this problem, you are asked to implement a very simple hash function, in any language you like, which takes an input array of bytes of any length and turns it into a 4-byte hash. It calculates the hash as follows:
If the input length measured in the number of bytes is not a multiple of 4, add 0s to the end until it is a multiple of 4.
Divide the input array into 4-byte blocks.
Calculate the exclusive-or of all blocks as the hash output.
Please use the hash function to find the hash of file “HW2P1input”, and submit it as the answer to this problem
Sample output:
Problem 1: if the file is \"abcdefghij\", the output should be 6d6e0e0c. Note that the file has 8 characters but the length is 11, because the last one is \'\ \' and is hidden.
Solution
These old hashes defined my requirements:
Without further ado, here\'s the fastest hash I\'ve been able to design that meets all the requirements. The comments describe how to use it.
Update: I\'m leaving the old hash in the text below, but it\'s obsolete, I have faster and more thorough hashes now. http://burtleburtle.net/bob/c/lookup3.c (2006) is about 2 cycles/byte, works well on 32-bit platforms, and can produce a 32 or 64 bit hash. SpookyHash (2011) is specific to 64-bit platforms, is about 1/3 cycle per byte, and produces a 32, 64, or 128 bit hash.
Most hashes can be modeled like this:
