Which BigInteger is needed for implementing SHA-256? SHA-256 has 64 hex symbols as output. I could use the data structure "string" to calculate the SHA-256 or a BigInteger.

Do I need uint256_t in the programming language C++ because I have 256 bits (0 and 1) and so the numbers from 0 to $2^{256} - 1$?

I first implemented SHA-256 with strings as variables and implemented functions for addition of two strings and so on. But maybe it is faster to implement SHA-256 with BigIntegers?


SHA-256 operates on 32-bit integers, with each 32-bit integer mapping to 4 bytes (big-endian). The 64-byte input block is turned into 16 32-bit integers (uint32_t[16]), the 32-byte state/output represents 8 32-bit integers (uint32_t[8]). At no point does SHA-256 use big integers.

SHA-512 is similar, but uses 64-bit integers instead.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.