Sha256 return empty value

Giganews Newsgroups
Subject: Sha256 return empty value
Posted by:  Alexandre (alexandrepires20…@yahoo.com.br)
Date: Mon, 09 Jun 2014

Hi Remy. Why this function returns a empty value ?

function TForm1crypt_SHA256(const AData, AKey: string): string;
var
  HMACSHA256: TIdHMACSHA256;
  KeyBytes: TIdBytes;
  DataBytes: TIdBytes;
  ResBytes: TIdBytes;
begin
  HMACSHA256 := TIdHMACSHA256.Create;
  try
    HMACSHA256.Key := ToBytes(AKey);
    DataBytes := ToBytes(AData);
    ResBytes := HMACSHA256.HashValue(DataBytes);
    Result := ToHex(ResBytes);
  finally
    HMACSHA256.Free;
  end;
end;

Thanks for some help
Alexandre
Brazil

Replies