CryptoSys API Library Manual

Example: Aes192.Decrypt  Aes192.Encrypt 

[VB6 equivalent: AES192_HexMode]

Dim strOutput As String
Dim strInput As String
Dim strHexKey As String
Dim sPlain As String
Dim sCipher As String
Dim strHexIV As String

' Encrypting 64 bytes (4 blocks) using AES-CBC with 192-bit key

strHexKey = "56e47a38c5598974bc46903dba29034906a9214036b8a15b"
strHexIV = "8ce82eefbea0da3c44699ed7db51b7d9"
sPlain = "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" _
    & "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" _
    & "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" _
    & "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"
sCipher = "738237036dfdde9dda3374fa182600c5" _
    & "38d9187a0299725d0a7fdbe844d77578" _
    & "1539e401b5597cbbfa836efd22d998d2" _
    & "1605d8df340622417b911467b5e51a12"

strInput = sPlain
' Set strOutput to be same length as strInput

Console.WriteLine("KY=" & " " & strHexKey)
Console.WriteLine("IV=" & " " & strHexIV)
Console.WriteLine("PT=" & " " & strInput)
' Encrypt in one-off process
strOutput = Aes192.Encrypt(strInput, strHexKey, Mode.CBC, strHexIV)
Console.WriteLine("CT=" & " " & strOutput)
Console.WriteLine("OK=" & " " & sCipher)
Debug.Assert(strOutput.ToLower = sCipher.ToLower)

' Decrypt to check
strInput = strOutput
strOutput = Aes192.Decrypt(strInput, strHexKey, Mode.CBC, strHexIV)
Console.WriteLine("P'=" & " " & strOutput)
Console.WriteLine("OK=" & " " & sPlain)
Debug.Assert(strOutput.ToLower = sPlain.ToLower)

See Also:
Aes192.Decrypt Method (String, String, Mode, String)
Aes192.Encrypt Method (String, String, Mode, String)

[Contents] [Index]

[PREV: Example: Aes128.Dispose ...]   [Contents]   [Index]   
   [NEXT: Example: Aes256.Decrypt ...]

Copyright © 2001-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-05-20T13:01:10Z.