Returns the error code after an unsuccessful call to AES128_Init or AES128_InitHex.
VB6/VBA
Debug.Print "Testing AES128_InitError ..." Dim hContext As Long Dim nRet As Long ' Try to initialise with an invalid key hContext = AES128_InitHex("THIS IS NOT HEX!", ENCRYPT, _ "CBC", "0123456789abcdef0123456789abcdef") If hContext = 0 Then nRet = AES128_InitError() Debug.Print "AES128_InitHex failed (" & apiErrorLookup(nRet) & ")" End If ' Try with an invalid mode hContext = AES128_InitHex("8A05FC5E095AF4848A08D328D3688E3D", _ ENCRYPT, "XXX", "0123456789abcdef0123456789abcdef") If hContext = 0 Then nRet = AES128_InitError() Debug.Print "AES128_InitHex failed (" & apiErrorLookup(nRet) & ")" End If
Output
Testing AES128_InitError ... AES128_InitHex failed (Invalid key (BAD_KEY_ERROR)) AES128_InitHex failed (Invalid mode (BAD_MODE_ERROR))
VB.NET
Console.WriteLine("Testing AES128_InitError ...") ''Dim hContext As Integer Dim nRet As Integer Dim oAes128 As Aes128 = Aes128.Instance() ' Try to initialise with an invalid key nRet = oAes128.InitEncrypt("THIS IS NOT HEX!", Mode.CBC, "0123456789abcdef0123456789abcdef") If nRet <> 0 Then ''nRet = oAes128.ErrCode Console.WriteLine("AES128_InitHex failed (" & General.ErrorLookup(oAes128.ErrCode) & ")") End If ' Try with an invalid mode ' <This cannot happen with the .NET method>
[Contents]