SHA-256: Difference between revisions

Content added Content deleted
(Add min)
No edit summary
Line 1,567: Line 1,567:
<pre>764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf</pre>
<pre>764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf</pre>
This is a moderately efficient implementation, about 100 MB/s on a 4096 bytes input buffer on a 32 bit system, using the ldc2 compiler. On a more modern CPU (Intel Ivy Bridge) using HyperThreading, handwritten assembly by Intel is about twice faster.
This is a moderately efficient implementation, about 100 MB/s on a 4096 bytes input buffer on a 32 bit system, using the ldc2 compiler. On a more modern CPU (Intel Ivy Bridge) using HyperThreading, handwritten assembly by Intel is about twice faster.
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| DCPsha256}} Part of '''DCPcrypt Cryptographic Component Library v2.1'''[https://bitbucket.org/wpostma/dcpcrypt2010] by David Barton.
<lang Delphi>
program SHA_256;


{$APPTYPE CONSOLE}

uses
System.SysUtils,
DCPsha256;

function SHA256(const Str: string): string;
var
HashDigest: array of byte;
d: Byte;
begin
Result := '';
with TDCP_sha256.Create(nil) do
begin
Init;
UpdateStr(Str);
SetLength(HashDigest, GetHashSize div 8);
final(HashDigest[0]);
for d in HashDigest do
Result := Result + d.ToHexString(2);
Free;
end;
end;

begin
Writeln(SHA256('Rosetta code'));
readln;

end.

</lang>
{{out}}
<pre>
764FAF5C61AC315F1497F9DFA542713965B785E5CC2F707D6468D7D1124CDFCF
</pre>
=={{header|DWScript}}==
=={{header|DWScript}}==
<lang delphi>PrintLn( HashSHA256.HashData('Rosetta code') );</lang>
<lang delphi>PrintLn( HashSHA256.HashData('Rosetta code') );</lang>