Xceed Encryption Library Documentation
Encrypting and decrypting from file to file (VB example)
Examples > Encrypting and decrypting from file to file (VB example)

Here are two examples for VB, one demonstrates encryption from file to file, the other demonstrates decryption from file to file. Both show how to use the Rijndael algorithm.

Visual Basic - Encryption Copy Code

' Encryption example 

Dim xEnc As New XceedEncryption
Call xEnc.License( "your license key" ) 

Dim vaBytesRead As Variant 

Set xEnc.EncryptionMethod = New XceedRijndaelEncryptionMethod 

On Error Resume Next

Call xEnc. EncryptionMethod.SetSecretKeyFromPassPhrase("This is a weak pass phrase!", 128)

Call xEnc.ProcessFile("c:\temp\source.txt", 0, 0, efpEncrypt, True, "c:\temp\encrypted.aes", False, vaBytesRead) 

If Err.Number = 0 Then
  Call MsgBox("Encryption successful!") 
Else
  Call MsgBox(Err.Description) 
End If

Visual Basic - Decryption Copy Code

Dim xEnc As New XceedEncryption

Call xEnc.License( "your license key" ) 

Dim vaBytesRead As Variant 

Set xEnc. EncryptionMethod = New XceedRijndaelEncryptionMethod 

On Error Resume Next

Call xEnc. EncryptionMethod.SetSecretKeyFromPassPhrase("This is a weak pass phrase!", 128)

Call xEnc.ProcessFile("c:\temp\encrypted.aes", 0, 0, efpDecrypt, True, "c:\temp\decrypted.txt", False, vaBytesRead) 

If Err.Number = 0 Then
  Call MsgBox("Decryption successful!") 
Else
  Call MsgBox(Err.Description) 
End If