Digital Signature with SHA256 RSA

Digital Signature with SHA256 RSA

To address potential issues related to digital signatures using SHA256 RSA, you can directly utilize the TScKey object as demonstrated in the following example:

uses ...ScBridge, ScUtils;

var
  Source, Signed: TBytes;
  aComment: string;
  Key: TScKey;
begin
  Key := TScKey.Create();
  Key.ImportFrom('MyKeyFile.pem', Password, aComment);
  Signed := Key.Sign(Source, haSHA2_256);
  if Key.VerifySign(Source, Signed, haSHA2_256) = True then
    // Sign is verified
  Key.Free;
end;

InfoImportant Note: The TScKey object is designed to work with TBytes buffers and cannot directly sign files. Therefore, ensure that the Source TBytes buffer is populated with the data you intend to sign before calling the TScKey.Sign method.

See also:
  1. Class TScKey;
  2. Method TScKey.Sign;