Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Security.Cryptography
- Imports System.Text
- Public Class Form1
- Public Shared Function DecryptTripleDES(ByVal sOut As String, ByVal sKey As String) As String
- Dim provider As New TripleDESCryptoServiceProvider
- Dim provider2 As New MD5CryptoServiceProvider
- sKey = Form1.ScrambleKey(sKey)
- provider.Key = provider2.ComputeHash(Encoding.ASCII.GetBytes(sKey))
- provider.Mode = CipherMode.ECB
- Dim transform As ICryptoTransform = provider.CreateDecryptor
- Dim inputBuffer As Byte() = Convert.FromBase64String(sOut)
- Return Encoding.ASCII.GetString(transform.TransformFinalBlock(inputBuffer, 0, inputBuffer.Length))
- End Function
- Private Shared Function ScrambleKey(ByVal v_strKey As String) As String
- Dim builder As New StringBuilder
- Dim length As Integer = v_strKey.Length
- Dim i As Integer = 1
- Do While (i <= length)
- Dim start As Integer = ((v_strKey.Length - i) + 1)
- builder.Append(Strings.Mid(v_strKey, start, 1))
- i += 1
- Loop
- Dim str2 As String = builder.ToString
- Return builder.ToString
- End Function
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- TextBox3.Text = DecryptTripleDES(TextBox1.Text, TextBox2.Text)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement