Implementing Sha256 and not getting the result I should get
Hello there,
The part in my program I'm stuck in gets a string, turns it to binary, pads the message and then divides it like Sha 256 does. Then, computes the hash with logical operations and bitwise operations.
Everything goes smooth and the 256-bit digest is saved to a file called "hash", but it's not what I should get.
For example: for string abc I should get:
ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad
But for some reason I don't.
Re: Implementing Sha256 and not getting the result I should get
Quote:
But for some reason I don't.
What do you get?
Have you worked through the math and the logic step by step to see where the program's computations and results differs from what you manually compute? When you find that point in the code, post what the manual results for the step is and show what the code does if you need help getting the code to do what your manual computations get.
Re: Implementing Sha256 and not getting the result I should get
The result is
f26cd891 87f5bf09 e14b7e36 2504dfec 307ed79c d1f3c788 e24793ec 00b1e84e
I guess the mismatches begins in the extension from 16 to 64 part.
Re: Implementing Sha256 and not getting the result I should get
After you work through the equations manually and find where the code is not doing what you expect, post your questions about why the statement(s) is not working as you want.
Re: Implementing Sha256 and not getting the result I should get
Man, I've been trying to do those things for days, I don't know what's wrong and where, If I would I would'nt post here. There's a certain peudo-code I've followed while writing the code, which is here:
SHA-2 - Wikipedia, the free encyclopedia
But again, I get a different result. maybe because all my variables are ints, I don't know! I need help to figure this out
Re: Implementing Sha256 and not getting the result I should get
Add printlns to show the results after each step of the program. Compare what is printed out with your manual computations. When you find the statement where the output is not the same as your manual computations, post that statement and explain what values the statement had for input and what it computed and show your manual computations that shows what the value should be.