CryptoSys API Library Manual

Example: Aes128.FileDecrypt  Aes128.FileEncrypt 

[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[])

[Contents] [Index]

[PREV: Example: Aes128.Decrypt ...]   [Contents]   [Index]   
   [NEXT: Example: Aes128.FileEncrypt ...]

Copyright © 2001-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-05-20T13:01:10Z.