[VB6 equivalent: AES128_File]
Const MY_PATH As String = ".\" Dim strFileOut As String, strFileIn As String, strFileChk As String Dim nRet As Integer Dim abKey() As Byte ' Construct full path names to files strFileIn = MY_PATH & "now.txt" strFileOut = MY_PATH & "now.aes128.enc.dat" strFileChk = MY_PATH & "now.aes128.chk.txt" ' Convert key to byte array abKey = Cnv.FromHex("0123456789ABCDEFF0E1D2C3B4A59687") ' Encrypt plaintext file to cipher nRet = Aes128.FileEncrypt(strFileOut, strFileIn, abKey, Mode.ECB, Nothing) If nRet <> 0 Then Console.WriteLine("Error " & nRet & ": " & General.ErrorLookup(nRet)) End If ' Now decrypt it nRet = Aes128.FileDecrypt(strFileChk, strFileOut, abKey, Mode.ECB, Nothing) If nRet <> 0 Then Console.WriteLine("Error " & nRet & ": " & General.ErrorLookup(nRet)) End If
See Also:
Aes128.FileDecrypt Method (String, String, Byte[], Mode, Byte[])
Aes128.FileEncrypt Method (String, String, Byte[], Mode, Byte[])