initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
Imports System.Text
|
||||
Imports System.Security.Cryptography
|
||||
|
||||
Public Class _3DES
|
||||
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
|
||||
Reference in New Issue
Block a user