Skip to content

zokhcat/sha-256-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

An attempt to implement SHA-256 from scratch using golang and reverse engineer.

Algorithm:

  • Intialization of Hash Values(H0-H7) and the constants (K0-K63) - done

  • Padding to ensure the message is near a 512 bits multiple. -- workflow of padding:

    1. add one "1" after converting the message to binary
    2. add "0"s till it satisfies 448(bits) mod 512(bits). In layman terms, there must be 64 bits space left after adding "0"s in the nearest 512 mulitple.
    3. In the end appending the 64-bit representation to the message we received.
  • Parsing the message by sptlitting it into 512-bit blocks. W[0]-W[63]

  • Scheduling the message: -- workflow of scheduling:

    1. W[0]-W[15] are extracted directly.
    2. Rest(W[16] - W[63]) are generated using this formula below: Scheduling Formula
  • Compression Function -- workflow of compression:

    1. Intialize a,b...h as the first H0-H7 values respectively
    2. For each 64 rounds, following manipulations are done: Compression where: helper Functions
  • Updating Hash after every 512-bit round:

    • H0 = H0 + a
    • H1 = H1 + b
    • H2 = H2 + c
    • H3 = H3 + d
    • H4 = H4 + e
    • H5 = H5 + f
    • H6 = H6 + g
    • H7 = H7 + h
  • Finally, Cocatenate the hash values to get the final 256-bit hash.

About

SHA 256 implementation in Golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages