Components and Libraries for Algorithms Development, discussions, problems and suggestions
 Page:1

# TOPIC:

## Help to understand with TDCP_sha256 6 years 9 months ago #11051

 Tigr Topic Author Offline Junior Member Posts: 54 Thank you received: 1 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! Please Log in or Create an account to join the conversation. Last edit: by Tigr.

## Help to understand with TDCP_sha256 6 years 9 months ago #11052

 Tigr Topic Author Offline Junior Member Posts: 54 Thank you received: 1 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; Please Log in or Create an account to join the conversation. Last edit: by Tigr.

## Help to understand with TDCP_sha256 6 years 9 months ago #11053

 Tigr Topic Author Offline Junior Member Posts: 54 Thank you received: 1 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.

## Help to understand with TDCP_sha256 6 years 8 months ago #11090

• Tigr
• Topic Author
• Offline
• Junior Member
• Posts: 54