Good, so these were Unicode issues. Just in case, if you want to know, this is my source Unit1.pas. You need a note and button form. Requires DCPCrypt2, LockBox2, LockBox3, and a hash block.
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, LbCipher, LbClass, StdCtrls, DCPcrypt2, DCPsha1, Hashes, uTPLb_CryptographicLibrary, uTPLb_BaseNonVisualComponent, uTPLb_Hash; type THashProc = reference to procedure(src: AnsiString; var output: AnsiString); TForm1 = class(TForm) Memo1: TMemo; btnTest: TButton; function Display(Buf: TBytes): String; procedure LockBox2Test; procedure LockBox3Test; procedure DCPCrypto2Test; procedure HashesTest; procedure btnTestClick(Sender: TObject); private { Private declarations } procedure RunTests(Name: String; HashFunc: THashProc); public { Public declarations } end; var Form1: TForm1; implementation uses uTPLb_StreamUtils; {$R *.dfm} procedure TForm1.btnTestClick(Sender: TObject); begin LockBox2Test; LockBox3Test; DCPCrypto2Test; HashesTest; end; procedure TForm1.DCPCrypto2Test; begin RunTests('DCPCrypto2', procedure(src: AnsiString; var output: AnsiString) var Digest: TSHA1Digest; Bytes : TBytes; SHA1 : TDCP_sha1; begin SHA1 := TDCP_sha1.Create(nil); SHA1.Init; SHA1.UpdateStr(src); SHA1.Final(Digest); SHA1.Destroy; SetLength(Bytes, 20); Move(Digest, Bytes[0], 20); output := Form1.Display(Bytes); end); end; function TForm1.Display(Buf: TBytes): String; var i: Integer; begin Result := ''; for i := 0 to 19 do Result := Result + Format('%0.2x', [Buf[i]]); Result := LowerCase(Trim(Result)); end; procedure TForm1.HashesTest; begin RunTests('Hashes', procedure(src: AnsiString; var output: AnsiString) begin output := CalcHash2(src, haSHA1) end) end; procedure TForm1.LockBox2Test; begin RunTests('LockBox2', procedure(src: AnsiString; var output: AnsiString) var Digest: TSHA1Digest; Bytes : TBytes; SHA1 : TLbSHA1; begin SHA1 := TLbSHA1.Create(nil); SHA1.HashStringA(src); SHA1.GetDigest(Digest); SHA1.Destroy; SetLength(Bytes, 20); Move(Digest, Bytes[0], 20); output := Form1.Display(Bytes); end); end; procedure TForm1.LockBox3Test; begin RunTests('LockBox3', procedure(src: AnsiString; var output: AnsiString) var Digest: TSHA1Digest; bytes : TBytes; P, Sz: integer; aByte: byte; s: string; SHA1 : THash; Lib : TCryptographicLibrary; begin Lib := TCryptographicLibrary.Create(nil); SHA1 := THash.Create(nil); SHA1.CryptoLibrary := Lib; SHA1.HashId := 'native.hash.SHA-1'; SHA1.Begin_Hash; SHA1.HashAnsiString(src); if not assigned(SHA1.HashOutputValue) then output := 'nil' else begin SetLength(Bytes, 20); Sz := SHA1.HashOutputValue.Size; if Sz <> 20 then output := Format('wrong size: %d', [Sz]) else begin P := 0; SHA1.HashOutputValue.Position := 0; while SHA1.HashOutputValue.Read(aByte, 1) = 1 do begin bytes[P] := aByte; Inc(P); end; output := Form1.Display(Bytes); end; end; SHA1.Destroy; Lib.Destroy; end) end; procedure TForm1.RunTests(Name: String; HashFunc: THashProc); var i: Integer; Tests: array [1 .. 2, 1 .. 2] of AnsiString; src, res: AnsiString; expected: String; begin // http://www.nsrl.nist.gov/testdata/ Tests[1][1] := 'abc'; Tests[1][2] := 'a9993e364706816aba3e25717850c26c9cd0d89d'; Tests[2][1] := 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'; Tests[2][2] := '84983e441c3bd26ebaae4aa1f95129e5e54670f1'; Memo1.Lines.Add(''); Memo1.Lines.Add('**' + Name + '**'); Memo1.Lines.Add(''); for i := 1 to 2 do begin src := Tests[i][1]; expected := Tests[i][2]; HashFunc(src, res); res := Trim(LowerCase(res)); if res = expected then begin Memo1.Lines.Add(Format(' Test %d passes', [i])) end else begin Memo1.Lines.Add(Format(' FAILED: %d (''%s'') ', [i, src])); Memo1.Lines.Add(Format(' Got: ''%s''', [res])); Memo1.Lines.Add(Format(' Expected: ''%s''', [expected])); end; end; end; end.