Xceed Encryption Library Documentation
Examples / Digitally signing a file (Delphi example)
In This Topic
    Digitally signing a file (Delphi example)
    In This Topic
    Delphi Copy Code

    { Signing example for Delphi, single pass } 

    uses XceedEncryptionLib_TLB
    var
      xSign : TXceedSigning; 
      xRSA : DXceedRSASigningMethod; 
      vaBytesRead : OleVariant; 
      vaSignature : OleVariant; 
      vaSeed : OleVariant; 
    begin
      xSign := TXceedSigning.Create( self ); 
      xSign.Licenser( 'your license key' ); 

      xRSA := CoXceedRSASigningMethod.Create();  

      try 
        { The following call to SetRandomKeyPair would, in the real world,
          be replaced by the assignment of a Private Key to the  
          PrivateKey property. }  

        vaSeed := varEmpty; 

        xRSA.SetRandomKeyPair( 512, vaSeed ); 
        xSign.SigningMethod := xRSA;  

        vaBytesRead := xSign.ReadFile( 'c:\temp\source.txt', 0, 0, efpSign, true ); 
        vaSignature := xRSA.Get_Signature;  

        { Do something with the Signature... }  

        ShowMessage( 'Signing successful!' );  

        vaBytesRead := xSign.ReadFile( 'c:\temp\source.txt', 0, 0, efpVerify, true ); 

        ShowMessage( 'Data verified successfully' ); 

      except 
        on xErr : Exception do 
          ShowMessage( xErr.Message ); 
      end;  

      xSign.Free; 
    end;