- Posts: 54
- Thank you received: 1
- Forum
- CodeTyphon Studio
- CodeTyphon Studio Components and Libraries
- Algorithms Development
- Help to understand with TDCP_sha256
×
Components and Libraries for Algorithms Development, discussions, problems and suggestions
Question Help to understand with TDCP_sha256
- Tigr
- Topic Author
- Offline
- Junior Member
-
Less
More
4 years 8 months ago - 4 years 8 months ago #11051
by Tigr
Help to understand with TDCP_sha256 was created by Tigr
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!
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: 4 years 8 months ago by Tigr.
Please Log in or Create an account to join the conversation.
- Tigr
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 54
- Thank you received: 1
4 years 8 months ago - 4 years 8 months ago #11052
by Tigr
Replied by Tigr on 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;
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: 4 years 8 months ago by Tigr.
Please Log in or Create an account to join the conversation.
- Tigr
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 54
- Thank you received: 1
4 years 8 months ago #11053
by Tigr
Replied by Tigr on 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
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
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 54
- Thank you received: 1
4 years 7 months ago #11090
by Tigr
Replied by Tigr on 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)))))
Post here which would then know where to find)))))
Attachments:
Please Log in or Create an account to join the conversation.