CryptoSys PKI Pro Manual

Example: Tdea.B64Mode  Tdea.Decrypt  Tdea.Encrypt 

[VB6 equivalent: TDEA_B64Mode]

Dim sHexCorrect As String
Dim sHexInput As String
Dim sHexKey As String
Dim sHexInitV As String
Dim sOutput As String
Dim sInput As String
Dim sKey As String
Dim sInitV As String
Dim sCorrect As String

' Start with input in hex
sHexInput = "5468697320736F6D652073616D706520636F6E74656E742E0808080808080808"
'            T h i s _ s o m e _ s a m p e _ c o n t e n t . (padding 8 x 08)
sHexKey = "737C791F25EAD0E04629254352F7DC6291E5CB26917ADA32"
sHexInitV = "B36B6BFB6231084E"
sHexCorrect = "d76fd1178fbd02f84231f5c1d2a2f74a4159482964f675248254223daf9af8e4"

' Convert to base64
sInput = System.Convert.ToBase64String(Cnv.FromHex(sHexInput))
sKey = System.Convert.ToBase64String(Cnv.FromHex(sHexKey))
sInitV = System.Convert.ToBase64String(Cnv.FromHex(sHexInitV))
sCorrect = System.Convert.ToBase64String(Cnv.FromHex(sHexCorrect))

Console.WriteLine("KY=" & " " & sKey)
Console.WriteLine("PT=" & " " & sInput)
Console.WriteLine("IV=" & " " & sInitV)
sOutput = Tdea.Encrypt(sInput, sKey, Mode.CBC, sInitV, EncodingBase.Base64)
Console.WriteLine("CT=" & " " & sOutput & " " & General.ErrorCode)
Console.WriteLine("OK=" & " " & sCorrect)

sInput = sOutput
sOutput = Tdea.Decrypt(sInput, sKey, Mode.CBC, sInitV, EncodingBase.Base64)
Console.WriteLine("P'=" & " " & sOutput & " " & General.ErrorCode)

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

[Contents] [Index]

[PREV: Example: Rsa.KeyBits ...]   [Contents]   [Index]   
   [NEXT: Example: Tdea.BytesMode ...]

Copyright © 2004-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-09-18T10:02:53Z.