Dom Jun 24, 2012 10:19 pm
DES
RC2
TripleDES
XOR
Creditos: pr0totip3
Fuente: Ax
Saludos
- Código:
Public Function DES_Encrypt(ByVal input As String, ByVal pass As String) As String
Dim DES As New System.Security.Cryptography.DESCryptoServiceProvider
Dim Hash_DES As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim encrypted As String = ""
Try
Dim hash(7) As Byte
Dim temp As Byte() = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 8)
DES.Key = hash
DES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(Input)
encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return encrypted
Catch ex As Exception
End Try
End Function
- Código:
Public Function DES_Decrypt(ByVal input As String, ByVal pass As String) As String
Dim DES As New System.Security.Cryptography.DESCryptoServiceProvider
Dim Hash_DES As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim decrypted As String = ""
Try
Dim hash(7) As Byte
Dim temp As Byte() = Hash_DES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 8)
DES.Key = hash
DES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(input)
decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return decrypted
Catch ex As Exception
End Try
End Function
RC2
- Código:
Public Function RC2_Encrypt(ByVal input As String, ByVal pass As String) As String
Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
Dim Hash_RC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim encrypted As String = ""
Try
Dim hash() As Byte = Hash_RC2.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
RC2.Key = hash
RC2.Mode = Security.Cryptography.CipherMode.ECB
Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = RC2.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return encrypted
Catch ex As Exception
End Try
End Function
- Código:
Public Function RC2_Decrypt(ByVal input As String, ByVal pass As String) As String
Dim RC2 As New System.Security.Cryptography.RC2CryptoServiceProvider
Dim Hash_RC2 As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim decrypted As String = ""
Try
Dim hash() As Byte = Hash_RC2.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
RC2.Key = hash
RC2.Mode = Security.Cryptography.CipherMode.ECB
Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = RC2.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(input)
decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return decrypted
Catch ex As Exception
End Try
End Function
TripleDES
- Código:
Public Function TripleDES_Encrypt(ByVal input As String, ByVal pass As String) As String
Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim encrypted As String = ""
Try
Dim hash(23) As Byte
Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 16)
Array.Copy(temp, 0, hash, 15, 8)
TripleDES.Key = hash
TripleDES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return encrypted
Catch ex As Exception
End Try
End Function
- Código:
Public Function TripleDES_Decrypt(ByVal input As String, ByVal pass As String) As String
Dim TripleDES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
Dim Hash_TripleDES As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim decrypted As String = ""
Try
Dim hash(23) As Byte
Dim temp As Byte() = Hash_TripleDES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 16)
Array.Copy(temp, 0, hash, 15, 8)
TripleDES.Key = hash
TripleDES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = TripleDES.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(input)
decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return decrypted
Catch ex As Exception
End Try
End Function
XOR
- Código:
Public Function XOR_Encrypt(ByVal Input As String, ByVal pass As String) As String
Dim out As New System.Text.StringBuilder
Dim u As Integer
For i As Integer = 0 To Input.Length - 1
Dim tmp As String = Hex(Asc(Input(i)) Xor Asc(pass(u)))
If tmp.Length = 1 Then tmp = "0" & tmp
out.Append(tmp)
If u = pass.Length - 1 Then u = 0 Else u = u + 1
Next
Return out.ToString
End Function
- Código:
Public Function XOR_Decrypt(ByVal Input As String, ByVal pass As String) As String
Dim out As New System.Text.StringBuilder
Dim u As Integer
For i As Integer = 0 To Input.Length - 1 Step +2
Dim tmp As String = Chr(("&H" & Input.Substring(i, 2)) Xor Asc(pass(u)))
out.Append(tmp)
If u = pass.Length - 1 Then u = 0 Else u = u + 1
Next
Return out.ToString
End Function
Creditos: pr0totip3
Fuente: Ax
Saludos