Amnedge1331
Member
|
More information about SHA2
Hi community,
I would like tu use SHA2 algoritm like here enter an Str (password) then get a Str crypted, but when i try it on esenthel with the method:
Code:
SHA2::Hash SHA2Mem(CPtr data, Int size);
I got an object SHA2::Hash wich contain:
Code:
struct{Byte b[32];};
struct{UInt i[ 8];};
struct{ULong l[ 4];};
And I don't know how to deal with this to have my Str cryped final.
Any tips ?
(This post was last modified: 03-04-2016 05:03 PM by Amnedge1331.)
|
|
03-04-2016 05:02 PM |
|
RedcrowProd
Member
|
RE: More information about SHA2
like a lot of things i havent start playing with hash atm, so little time and some much to do !
but isnt this what you are looking for ? C Hash& operator()( ); // finalize and get hash result
|
|
03-04-2016 07:51 PM |
|
Esenthel
Administrator
|
RE: More information about SHA2
Yes,
SHA2::Hash gives you the hash result.
The hash is just a few bytes.
Is it my understanding you want to display the hash in text format?
If so you can use the TextHexMem function:
TextHexMem(&sha2.hash(), SIZE(sha2.hash()), ..);
|
|
03-04-2016 11:03 PM |
|
Amnedge1331
Member
|
RE: More information about SHA2
Ok I see thank, however I try it and i get a different result from the website of my first post, here is my code:
Code:
Str pass="coucou";
SHA2 hash;
hash.update(pass, SIZE(pass));
finalS=TextHexMem(&hash(), SIZE(hash()));
I try this too but same result:
Code:
Str pass="coucou";
SHA2::Hash hash=SHA2Mem(pass, SIZE(pass));
finalS=TextHexMem(&hash, SIZE(hash));
Result is: d2c5ecdb878dad5a80480d89672d0a7111d70bc8da3e8203be4e169c50ba5415
On the website with "coucou" i get:
110812f67fa1e1f0117f6f3d70241c1a42a7b07711a93c2477cc516d9042f9db
(This post was last modified: 03-05-2016 11:06 AM by Amnedge1331.)
|
|
03-05-2016 11:05 AM |
|
Esenthel
Administrator
|
RE: More information about SHA2
Str is 16-bit char, maybe you want to use Str8
Also you need to use pass(), and pass.length()*SIZE(..) as the parameters for sha
|
|
03-05-2016 11:12 AM |
|
Amnedge1331
Member
|
RE: More information about SHA2
Ok but after try this in 16 and 8bit it still wrong, here are my try:
Code:
Str pass="coucou";
SHA2::Hash hash=SHA2Mem(pass(), SIZE(pass())*pass.length());
Str finalS=TextHexMem(&hash, SIZE(hash));
Code:
Str8 pass="coucou";
SHA2::Hash hash=SHA2Mem(pass(), SIZE(pass())*pass.length());
Str8 finalS=TextHexMem(&hash, SIZE(hash));
Code:
Str pass="coucou";
SHA2::Hash hash=SHA2Mem(pass(), SIZE(pass)*pass.length());
Str finalS=TextHexMem(&hash, SIZE(hash));
Code:
Str8 pass="coucou";
SHA2::Hash hash=SHA2Mem(pass(), SIZE(pass)*pass.length());
Str8 finalS=TextHexMem(&hash, SIZE(hash));
|
|
03-06-2016 01:08 AM |
|
Esenthel
Administrator
|
RE: More information about SHA2
SIZE needs to be SIZE(*pass())
Code:
Str8 pass="coucou";
SHA2::Hash hash=SHA2Mem(pass(), SIZE(*pass())*pass.length());
Str finalS=TextHexMem(&hash, SIZE(hash));
|
|
03-06-2016 02:33 AM |
|
Amnedge1331
Member
|
RE: More information about SHA2
Ok nice thank you a lot, not easy to understand it
|
|
03-06-2016 03:18 PM |
|