Windows 10, Visual Studio 2019, C++
I am working on some code that will include SHA-256. In my readings about it, articles mention the use of “addition modulo 32.” When I read about that operation the effect seems to be just add the two 32 bit numbers and disregard any carry into bit 33. The words used go into much more mathematical detail and I am concerned that I am missing something. Do I have the essence correct?
Thanks for the simplification and confirmation.
Is there any specific C++ syntax to do this?
If I declare some unsigned ints of size 32 and just add them it seems that would do this trick automatically.
that is correct. It may be 'technically' undefined to use the result of an overflow, but in practice, pretty sure all platforms drop the overflow and the result is like a modulo.
I found that value to hex string took longer than the shuffle: sha is pretty fast math side.
The information there needs an update. The use of signed and unsigned char, int, long int, etc, is imprecise and is not standardized. If the size matters, use stdint.h. It has a set of precise definitions: