CryptoSys PKI Pro Manual

Example: Tdea.File  Tdea.FileDecrypt  Tdea.FileEncrypt 

[VB6 equivalent: TDEA_File]

Const MY_PATH As String = ""
Dim aKey() As Byte
Dim strFileOut As String
Dim strFileIn As String
Dim strFileChk As String
Dim nRet As Integer

' Construct full path names to files
strFileIn = MY_PATH & "hello.txt"
strFileOut = MY_PATH & "hello.tdea.enc.dat"
strFileChk = MY_PATH & "hello.tdea.chk.txt"

' Create the key as an array of bytes
' This creates an array of 24 bytes {&HFE, &HDC, ... &H10}
aKey = Cnv.FromHex("fedcba9876543210fedcba9876543210fedcba9876543210")

' Encrypt plaintext file to ciphertext
' Output file = 16-byte ciphertext file hello.enc
nRet = Tdea.FileEncrypt(strFileOut, strFileIn, aKey, Mode.ECB, Nothing)
Console.WriteLine("TDEA_File(ENCRYPT) returns " & nRet & "")

' Now decrypt it
nRet = Tdea.FileDecrypt(strFileChk, strFileOut, aKey, Mode.ECB, Nothing)
Console.WriteLine("TDEA_File(DECRYPT) returns " & nRet & "")

See Also:
Tdea.FileDecrypt Method (String, String, Byte[], Mode, Byte[])
Tdea.FileEncrypt Method (String, String, Byte[], Mode, Byte[])

[Contents] [Index]

[PREV: Example: Tdea.BytesMode ...]   [Contents]   [Index]   
   [NEXT: Example: Tdea.Decrypt ...]

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