MarshallSoft

Visual Basic Advanced Encryption Standard (AES) Example


Private Function EncryptFile(ByRef KeyBuffer As String, ByRef InFile As String, ByRef OutFile As String) As Integer
Dim Code As Integer
Dim Control As String
Dim Vector As String
' vector not used in ECB mode
Vector = Chr(0)
Control = "*"
' initialize for encryption in ECB mode
Code = aesInitAES(KeyBuffer, Vector, AES_ECB_MODE, AES_ENCRYPT, Control)
If Code < 0 Then
  EncryptFile = Code
  Exit Function
End If
' encrypt the file (InFile -> OutFile)
Code = aesEncryptFile(Control, InFile, OutFile)
EncryptFile = Code
End Function

MSC Logo

HOME PAGE
MARSHALLSOFT is a trademark of MarshallSoft Computing, Inc.