AES192_B64Mode encrypts or decrypts data
represented as a base64 string
using a specified mode. The key and initialization vector
are represented as base64 strings.
Public Declare Function AES192_B64Mode Lib "diCryptoSys.dll"
(ByVal strOutput As String, ByVal strInput As String,
ByVal strKey As String, ByVal bEncrypt As Boolean,
ByVal strMode As String, ByVal strIV As String) As Long
nRet = AES192_B64Mode(strOutput, strInput, strKey, bEncrypt, strMode, strIV)
String of sufficient length to receive the output.String containing the input data in base64.String containing the key in base64.Boolean direction flag:
set as True to encrypt or False
to decrypt.String specifying the confidentiality mode:String containing the initialization vector (IV), if required,
in base64.
long _stdcall AES192_B64Mode(char *strOutput, const char *strInput,
const char *strKey, int bEncrypt, const char *strMode, const char *sIV);
Long: If successful, the return value is 0;
otherwise it returns a non-zero error code.
Aes192.Encrypt Method (String, String, Mode, String, EncodingBase)
Aes192.Decrypt Method (String, String, Mode, String, EncodingBase)
The length of the input string strInput must represent a multiple of the block size (16 bytes) when decoded.
If not, an error will be returned.
The initialization vector
string strIV must represent exactly 16 bytes
unless strMode is ECB, in which case strIV is ignored (use "").
The key strKey must represent exactly 24 bytes, the required key length.
The output string strOutput must be set up with at least the same
number of characters as the input string before calling.
The variables strOutput and strInput should be different.
This example is the same data as for AES192_HexMode,
except the data is in base64 format.
Dim nRet As Long Dim strOutput As String Dim strInput As String Dim strKey As String Dim strIV As String Dim bEncrypt As Boolean Dim sCorrect As String strInput = "oKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y" _ & "9vr/AwcLDxMXGx8jJysvMzc7P0NHS09TV1tfY2drb3N3e3w==" strKey = "VuR6OMVZiXS8RpA9uikDSQapIUA2uKFb" strIV = "jOgu776g2jxEaZ7X21G32Q==" sCorrect = "c4I3A2393p3aM3T6GCYAxTjZGHoCmXJdCn/b6" _ & "ETXdXgVOeQBtVl8u/qDbv0i2ZjSFgXY3zQGIkF7kRRnteUaEg==" ' Set strOutput to be same length as strInput strOutput = String(Len(strInput), " ") Debug.Print "KY="; strKey Debug.Print "IV="; strIV Debug.Print "PT="; strInput nRet = AES192_B64Mode(strOutput, strInput, strKey, ENCRYPT, "CBC", strIV) Debug.Print "CT="; strOutput; nRet Debug.Print "OK="; sCorrect strInput = strOutput nRet = AES192_B64Mode(strOutput, strInput, strKey, DECRYPT, "CBC", strIV) Debug.Print "P'="; strOutput; nRet
This should result in output as follows:
KY=VuR6OMVZiXS8RpA9uikDSQapIUA2uKFb IV=jOgu776g2jxEaZ7X21G32Q== PT=oKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/ AwcLDxMXGx8jJysvMzc7P0NHS09TV1tfY2drb3N3e3w== CT=c4I3A2393p3aM3T6GCYAxTjZGHoCmXJdCn/b6ETXdXg VOeQBtVl8u/qDbv0i2ZjSFgXY3zQGIkF7kRRnteUaEg== 0 OK=c4I3A2393p3aM3T6GCYAxTjZGHoCmXJdCn/b6ETXdXg VOeQBtVl8u/qDbv0i2ZjSFgXY3zQGIkF7kRRnteUaEg== P'=oKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr/ AwcLDxMXGx8jJysvMzc7P0NHS09TV1tfY2drb3N3e3w== 0
AES192_HexMode
AES192_BytesMode