Xceed Encryption Library Documentation
Examples / Encrypting and decrypting from file to memory (Delphi example)
In This Topic
    Encrypting and decrypting from file to memory (Delphi example)
    In This Topic

    Here are is an example for Delphi that demonstrates encryption from file to memory in a single pass. It shows how to use the Rijndael algorithm.

    Delphi Copy Code

    uses XceedEncryptionLib_TLB 

    var
      xEnc : TXceedEncryption; 
      xRijndael : DXceedRijndaelEncryptionMethod; 
      vaBytesRead : OleVariant;  
    begin
      xEnc := TXceedEncryption.Create( self ); 
      xEnc.License( 'your license key' ); 

      xRijndael := CoXceedRijndaelEncryptionMethod.Create();  

      try 
        xRijndael.SetSecretKeyFromPassPhrase( 'This is a weak pass phrase!', 128 ); 

        xEnc. EncryptionMethod := xRijndael; 
        xEnc.ReadFile( 'c:\temp\source.txt', 0, 0, efpEncrypt, true, vaBytesRead ); 

        ShowMessage( 'Encryption successful!' ); 
      except 
        on xErr : Exception do 
          ShowMessage( xErr.Message ); 
      end;  

      xEnc.Free; 
    end;