Xceed Encryption Library Documentation
Encrypting and decrypting from file to memory (C# example)
Examples > Encrypting and decrypting from file to memory (C# example)
C# - Encryption Copy Code

XceedEncryptionLib.XceedEncryption encrypt = new XceedEncryptionLib.XceedEncryptionClass(); 

encrypt.License( @"your license key" ); 

XceedEncryptionLib.XceedRijndaelEncryptionMethod rijndael = new XceedEncryptionLib.XceedRijndaelEncryptionMethodClass();            

try
{
  rijndael.SetSecretKeyFromPassPhrase( "This is a weak pass phrase", 128 );

  encrypt.EncryptionMethod = rijndael;      

  object bytesRead = null;

  object encryptedData = encrypt.ReadFile( @"c:\test\file.txt", 0, 0,
                                           XceedEncryptionLib.EXEFileProcessing.efpEncrypt, true,
                                           ref bytesRead );
}
catch( System.Runtime.InteropServices.COMException except )
{
  MessageBox.Show( except.ToString() );
}

C# - Decryption Copy Code

XceedEncryptionLib.XceedEncryption encrypt = new XceedEncryptionLib.XceedEncryptionClass(); 

encrypt.License( @"your license key" ); 

XceedEncryptionLib.XceedRijndaelEncryptionMethod rijndael = new XceedEncryptionLib.XceedRijndaelEncryptionMethodClass();            

try
{
  rijndael.SetSecretKeyFromPassPhrase( "This is a weak pass phrase", 128 );

  encrypt.EncryptionMethod = rijndael;      

  encrypt.WriteFile( ref encryptedData, XceedEncryptionLib.EXEFileProcessing.efpDecrypt, true, 
                     @"c:\test\file.txt", false );        
}
catch( System.Runtime.InteropServices.COMException except )
{
  MessageBox.Show( except.ToString() );
}