Xceed Encryption Library Documentation
Examples / Encrypting and decrypting from memory to file (VB.NET example)
In This Topic
    Encrypting and decrypting from memory to file (VB.NET example)
    In This Topic
    VB.NET - Encryption Copy Code

    Dim encrypt As New XceedEncryptionLib.XceedEncryptionClass() 

    encrypt.License( "your license key" ) 

    Dim rijndael As New XceedEncryptionLib.XceedRijndaelEncryptionMethodClass()
    Dim source As Object = "This is the data to encrypt"

    Try
      rijndael.SetSecretKeyFromPassPhrase( "This is a weak pass phrase", 128 )

      encrypt.EncryptionMethod = rijndael
      encrypt.WriteFile( source, XceedEncryptionLib.EXEFileProcessing.efpEncrypt, true, _
                         "c:\test\file.enc", false )

     

    Catch except As System.Runtime.InteropServices.COMException

    MessageBox.Show( except.ToString() )

    End Try

    VB.NET - Decryption Copy Code

    Dim encrypt As New XceedEncryptionLib.XceedEncryptionClass() 

    encrypt.License( "your license key" ) 

    Dim rijndael As New XceedEncryptionLib.XceedRijndaelEncryptionMethodClass() 

    Try
      rijndael.SetSecretKeyFromPassPhrase( "This is a weak pass phrase", 128 )

      encrypt.EncryptionMethod = rijndael 

      Dim bytesRead As Object = Nothing
      Dim decryptedData As Object = encrypt.ReadFile( "c:\test\file.enc", 0, 0, _
                                                      XceedEncryptionLib.EXEFileProcessing.efpDecrypt,
                                                      true, bytesRead ) 

      MessageBox.Show( System.Text.Encoding.Unicode.GetString( CType( decryptedData, byte() ) ) )       
    Catch except As System.Runtime.InteropServices.COMException
      MessageBox.Show( except.ToString() )
    End Try