AES192_FileHex encrypts or decrypts a file
using a specified mode. The key and initialization vector
are passed as hexadecimal strings.
Public Declare Function AES192_FileHex Lib "diCryptoSys.dll"
(ByVal strFileOut As String, ByVal strFileIn As String,
ByVal strHexKey As String,
ByVal bEncrypt As Boolean, ByVal strMode As String, ByVal strHexIV As String) As Long
nRet = AES192_FileHex(strFileOut, strFileIn, strHexKey, bEncrypt, strMode, strHexIV)
String with the full path name of the output
file to be created.String with the full path name of the input file
to be processed.String containing the key in hexadecimal.Boolean direction flag:
set as True to encrypt or False
to decrypt.String specifying the confidentiality mode:String containing the initialization vector (IV)
in hexadecimal.
long _stdcall AES192_FileHex(const char *lpszFileOut, const char *lpszFileIn,
const char *lpszKey, int bEncrypt, const char *lpszMode, const char *lpszIV);
Long: If successful, the return value is 0;
otherwise it returns a non-zero error code.
Aes192.FileEncrypt Method (String, String, String, Mode, String)
Aes192.FileDecrypt Method (String, String, String, Mode, String)
The key string strHexKey
must be exactly 48 hexadecimal characters long
(i.e. representing exactly 24 bytes/192 bits).
The initialization vector strHexIV
must be exactly 32 hexadecimal characters long
(i.e. representing the block size of exactly 16 bytes), except for ECB mode, where it is ignored (use "").
The output file strFileOut will be overwritten without warning.
If there is an error [new in version 3.3], the output file will not exist.
The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of
[CMS],
which is the same as the padding method in [PKCS7] and [PKCS5].
This example will encrypt the file "bigfile.dat" in CBC mode using the 192-bit key 000102030405060708090a0b0c0d0e0f1011121314151617 and initialization vector 0x0123456789abcdef0123456789abcdef. The output file "bigfile.cbc" will be created or overwritten.
Dim nRet As Long
nRet = AES192_FileHex("bigfile.cbc", "bigfile.dat", _
"000102030405060708090a0b0c0d0e0f1011121314151617", _
ENCRYPT, "CBC", "0123456789abcdef0123456789abcdef")
If nRet <> 0 Then
Debug.Print "AES192_FileHex failed: " & apiErrorLookup(nRet)
Else
Debug.Print "AES192_FileHex encrypted file OK"
End If