Encrypts or decrypts a file using a specified mode. The key and initialization vector are passed as hexadecimal strings.
Public Declare Function BLF_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 = BLF_FileHex(strFileOut, strFileIn, strHexKey, bEncrypt, strMode, strHexIV)
long __stdcall BLF_FileHex(const char *szFileOut, const char *szFileIn, const char *szKey, int fEncrypt, const char *szMode, const char *sHexIV);
If successful, the return value is 0; otherwise it returns a non-zero error code.
Blowfish.FileEncrypt Method (String, String, String, Mode, String)
Blowfish.FileDecrypt Method (String, String, String, Mode, String)
The initialization vector
string szHexIV must be exactly 16 hex characters long
(i.e. representing exactly 8 bytes) unless szMode is ECB,
in which case szHexIV is ignored (use ""
).
The key szKey can be any even length between 2 and 112 hexadecimal characters.
Valid hexadecimal characters are [0-9A-Fa-f].
The output file szFileOut 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].
Note that even though the parameters are in hexadecimal-encoded form, the encrypted file is still binary.
This example will encrypt the file "bigfile.dat" in CBC mode using the key
0xfedcba9876543210fedcba9876543210
and initialization vector
0x0123456789abcdef
. The output file "bigfile.cbc" will be created or
overwritten.
Dim nRet As Long ' Encrypt plaintext file to cipher nRet = BLF_FileHex("bigfile.cbc", "bigfile.dat", _ "fedcba9876543210fedcba9876543210", ENCRYPT, "CBC", "0123456789abcdef") Debug.Print nRet