I wanted to share some Cryptographic Algorithms with you all and by the way cryptographic is a very important resource for programmers all the way .
Triple DES - triple data encryption (3DES)
Imports System.Text
Imports System.Security.Cryptography
Public Class 3_DES
Public Shared Function Encrypt(ByVal toEncrypt As String, ByVal key As String, ByVal useHashing As Boolean) As String
Dim keyArray As Byte()
Dim toEncryptArray As Byte() = UTF8Encoding.UTF8.GetBytes(toEncrypt)
If useHashing Then
Dim hashmd5 As New MD5CryptoServiceProvider()
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key))
Else
keyArray = UTF8Encoding.UTF8.GetBytes(key)
End If
Dim tdes As New TripleDESCryptoServiceProvider()
tdes.Key = keyArray
tdes.Mode = CipherMode.ECB
tdes.Padding = PaddingMode.PKCS7
Dim cTransform As ICryptoTransform = tdes.CreateEncryptor()
Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)
Return Convert.ToBase64String(resultArray, 0, resultArray.Length)
End Function
End Class

