CryptoSys API Library Manual

Example: Aes128.Dispose  Aes128.InitDecrypt  Aes128.Instance  Aes128.Update 

[VB6 equivalent: AES128_Update]

Dim nRet As Integer
Dim abBlock() As Byte
Dim abKey() As Byte
Dim abCorrect() As Byte
Dim j As Integer
Dim oAes128 As Aes128 = Aes128.Instance()

' File: ecb_d_m.txt
' KEYSIZE=128 I=2
' KEY=A7BC3BD0EABD9EBA981E23E6FFC9C9C2
' CT=E3FD51123B48A2E2AB1DB29894202222
' PT=877B88A77AEF04F05546539E17259F53
' Convert to Byte format
abKey = Cnv.FromHex("A7BC3BD0EABD9EBA981E23E6FFC9C9C2")
abBlock = Cnv.FromHex("E3FD51123B48A2E2AB1DB29894202222")
abCorrect = Cnv.FromHex("877B88A77AEF04F05546539E17259F53")

Console.WriteLine("AES Monte Carlo ECB Mode Decrypt:")
Console.WriteLine("KY=" & " " & Cnv.ToHex(abKey))
Console.WriteLine("CT=" & " " & Cnv.ToHex(abBlock))

nRet = oAes128.InitDecrypt(abKey, Mode.ECB, Nothing)
If nRet <> 0 Then
    Console.WriteLine("ERROR: Failed to set context")
    Exit Sub
End If
' Do 10,000 times
For j = 0 To 9999
    abBlock = oAes128.Update(abBlock)
Next
Console.WriteLine("PT=" & " " & Cnv.ToHex(abBlock))
Console.WriteLine("OK=" & " " & Cnv.ToHex(abCorrect))
oAes128.Dispose()

Debug.Assert(Cnv.ToHex(abCorrect) = Cnv.ToHex(abBlock))

See Also:
Aes128.Update Method (Byte[])

[Contents] [Index]

[PREV: Example: Aes128.ErrCode ...]   [Contents]   [Index]   
   [NEXT: Example: Aes128.Dispose ...]

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