Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. The process is carried out in one step in Electronic Codebook (EBC) mode.
@deprecated use
AES192_HexMode
with strMode="ECB"
.
Public Declare Function AES192_Hex Lib "diCryptoSys.dll"
(ByVal strOutput As String, ByVal strInput As String, ByVal strHexKey As String,
ByVal bEncrypt As Boolean) As Long
nRet = AES192_Hex(strOutput, strInput, strHexKey, bEncrypt)
long __stdcall AES192_Hex(char *szOutput, const char *szInput, const char *szKey, int fEncrypt);
If successful, the return value is 0; otherwise it returns a non-zero error code.
Aes192.Encrypt Method (String, String, Mode, String)
Aes192.Decrypt Method (String, String, Mode, String)
with mode=Mode.ECB
.
The length of the input string szInput must be a multiple of 32 hex characters long (i.e. representing a multiple of the block size of 16 bytes). The key string szHexKey must be exactly 48 hex characters long (i.e. representing exactly 24 bytes/192 bits). The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].
This function is equivalent to
nRet = AES192_HexMode(strOutput, strInput, strHexKey, bEncrypt, "ECB", 0)
This example is taken from FIPS 197 Appendix C.
Dim nRet As Long Dim strOutput As String Dim strInput As String Dim strHexKey As String Dim sPlain As String Dim sCipher As String 'FIPS-197 'C.2 AES-192 (Nk=6, Nr=12) 'PLAINTEXT: 00112233445566778899aabbccddeeff 'KEY: 000102030405060708090a0b0c0d0e0f1011121314151617 strHexKey = "000102030405060708090a0b0c0d0e0f1011121314151617" sPlain = "00112233445566778899aabbccddeeff" sCipher = "dda97ca4864cdfe06eaf70a0ec0d7191" strInput = sPlain ' Set strOutput to be same length as strInput strOutput = String(Len(strInput), " ") Debug.Print "KY=" & strHexKey Debug.Print "PT=" & strInput ' Encrypt in one-off process nRet = AES192_Hex(strOutput, strInput, strHexKey, ENCRYPT) Debug.Print "CT=" & strOutput; nRet Debug.Print "OK=" & sCipher ' Now decrypt back to plain text strInput = strOutput nRet = AES192_Hex(strOutput, strInput, strHexKey, DECRYPT) Debug.Print "P'=" & strOutput; nRet
This should result in output as follows:
KY=000102030405060708090a0b0c0d0e0f1011121314151617 PT=00112233445566778899aabbccddeeff CT=DDA97CA4864CDFE06EAF70A0EC0D7191 0 OK=dda97ca4864cdfe06eaf70a0ec0d7191 P'=00112233445566778899AABBCCDDEEFF 0