Dim TDes As New TripleDESCryptoServiceProvider Dim KeyString As String = "0102030405060708090A0B0C0D0E0F10" Dim DataString As String = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" Dim DataBytes(15) As Byte Dim KeyBytes(15) As Byte Dim EncryptBytes() As Byte Dim EncryptString As String = "" Dim x As Byte For x = 0 To KeyString.Length - 1 Step 2 KeyBytes(x / 2) = Val("&h" & Mid(KeyString, x + 1, 2)) Next x For x = 0 To DataString.Length - 1 Step 2 DataBytes(x / 2) = Val("&h" & Mid(DataString, x + 1, 2)) Next x TDes.KeySize = 128 TDes.Key = KeyBytes TDes.Mode = CipherMode.ECB Dim ms As New System.IO.MemoryStream Dim encStream As New CryptoStream(ms, TDes.CreateEncryptor(), _ System.Security.Cryptography.CryptoStreamMode.Write) encStream.Write(DataBytes, 0, DataBytes.Length) encStream.FlushFinalBlock() EncryptBytes = ms.ToArray() For x = 0 To EncryptBytes.Length - 1 EncryptString = EncryptString & Mid("0" & Hex(EncryptBytes(x)), _ Len(Hex(EncryptBytes(x))), 2) Next x MessageBox.Show(EncryptString & " - " & Len(EncryptString) / 2)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)