Homepage
About
Projects
SHA-1 Alghorithm
How does it work?
Pre-process:
1. Split Input String into an array of individual characters and convert to ASCII code
2. Convert ASCII codes into binary code.
3. Pad zeros to the front of each code until the codes are 8 bits long.
4. Join binary codes together and append a '1'
5. Pad the binary message with zeros until length = 512 mod 448.
6. Get the Length of the 8-bit ASCII code array from step 3 and convert it to binary.
7. Pad with zeros until its 64 characters long
8. Append to previous binary message from step 5.
SHA-1 Algorithm:
1. Break the message into an array of 512 character chunks
2. Break each chunk into a subarray of 16 x 32 'words'
3. Loop through each chunk and extend it to 80 newly generated 'words' using the subarray
4. Initialize some variables.
H0 = 0x67452301
H1 = 0xEFCDAB89
H2 = 0x98BADCFE
H3 = 0x10325476
H4 = 0xC3D2E1F0
[a, b, c, d, e] = [H0, H1, H2, H3, H4]
5. For each chunk: bitwise operation and variable reassignment.
H0 = 0x67452301
H1 = 0xEFCDAB89
H2 = 0x98BADCFE
H3 = 0x10325476
H4 = 0xC3D2E1F0
H0 = null
H1 = null
H2 = null
H3 = null
H4 = null
6. Combine main hash values of hashed variables and return.
Back to top