Forum
× Components and Libraries for Algorithms Development, discussions, problems and suggestions

Question Help to understand with TDCP_sha256

  • Tigr
  • Tigr's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 1 week ago - 3 months 1 week ago #11051 by Tigr
Tigr created the topic: Help to understand with TDCP_sha256
Please explain what's wrong and what's missing!?
Using the component TDCP_sha256 trying to get the string:
0f3aca61475521f3b76d84d86237885fbe30e34f9efe7ddf457aae123b6cdbe0
feeding line:
1b90ee9449c7709cdce4f8e105970aea7eb23d576b636693d4117f9899c42ee9
But in fact display it in the memo is not true! I assume this as the character encoding is different... how to get the correct result?


procedure TForm1.Button1Click(Sender: TObject);
var s,r:string;
begin
S:='1b90ee9449c7709cdce4f8e105970aea7eb23d576b636693d4117f9899c42ee9';
form1.DCP_sha256_1.Init;
form1.DCP_sha256_1.Update(s,64);
SetLength(r, (DCP_sha256_1.HashSize div 8) div SizeOf(Char));
form1.DCP_sha256_1.Final(r[1]);
memo1.Lines.Add(r);

end;

For earlier grateful!
Last Edit: 3 months 1 week ago by Tigr.

Please Log in or Create an account to join the conversation.

  • Tigr
  • Tigr's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 1 week ago - 3 months 1 week ago #11052 by Tigr
Tigr replied the topic: Help to understand with TDCP_sha256
decided so!

function DigestToStr(Digest: array of byte): string;
var
i: Integer;
begin
Result := '';
for i := 0 to Length(Digest) -1 do
Result := Result + LowerCase(IntToHex(Digest, 2));
end;

function GetStringHash(Source: string): string;
var
Hash: TDCP_sha256;
Digest: array[0..31] of Byte;
begin
Hash := TDCP_sha256.Create(nil);
Hash.Init;
Hash.UpdateStr(Source);
Hash.Final(Digest);
Hash.Free;
Result := DigestToStr(Digest);
end;

procedure TForm1.Button1Click(Sender: TObject);
var s,r:string;
begin
S:='1b90ee9449c7709cdce4f8e105970aea7eb23d576b636693d4117f9899c42ee9';


r:=GetStringHash(s);
memo1.Lines.Add(r);
memo1.Lines.Add(inttostr(length(r)));

end;
Last Edit: 3 months 1 week ago by Tigr.

Please Log in or Create an account to join the conversation.

  • Tigr
  • Tigr's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 months 1 week ago #11053 by Tigr
Tigr replied the topic: Help to understand with TDCP_sha256
Question!
How you can implement this method in javascript in the framework described above? where Skey is a hash-256, and text-is a text...

var hash = crypto.createHmac('sha512', Skey).update(text).digest('hex'); // code javaScript

Please Log in or Create an account to join the conversation.

  • Tigr
  • Tigr's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
2 months 2 days ago #11090 by Tigr
Tigr replied the topic: Help to understand with TDCP_sha256
Here is a good module found in the Internet with a full-time dedicated hash-functions!
Post here which would then know where to find)))))
Attachments:

Please Log in or Create an account to join the conversation.