DES Encryption using vb.net

danishce

Member
Joined
Apr 2, 2007
Messages
15
Programming Experience
3-5
I have studied that DES CBC algorithm generate 64 bits (8 byte Hex) encrypted output but when i implement the algorithm in vb.net it gives the same length output as my plain text.i need help on how i obtain 8 byte encrypted output.

VB.NET:
Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}

Dim plainText As String
plainText = "HelloWorldhjslkajldalkdjlaksjdlakdja" 
Dim DES As New System.Security.Cryptography.DESCryptoServiceProvi der
' Set the cipher mode.
DES.Mode = System.Security.Cryptography.CipherMode.CBC
' Create the encryptor.
Dim DESEncrypt As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor(Me.key, Me.iv)
' Get a byte array of the string.
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(plainText )
' Transform and return the string.
Dim keyout As String
keyout = Convert.ToBase64String(DESEncrypt.TransformFinalBl ock(Buffer, 0, Buffer.Length))
 
Back
Top