i'm using the following algorithm to encrypt and decrypt a string in VB.NET and wanted to do that same method in Android also. can anyone tell me the similar algorithm for Android (Java)
Encryption:
Private Function decryptStr(ByVal key As String, ByVal enc As String) As String
Try
DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(key))
DES.Mode = System.Security.Cryptography.CipherMode.ECB
Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(enc)
respass = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return respass
Catch ex As Exception
Return enc
End Try
End Function
Decryption:
Public Function decryptStr(ByVal encrypted As String, ByVal key As String) As String
Try
DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(key))
DES.Mode = System.Security.Cryptography.CipherMode.ECB
Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(encrypted)
respass = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return respass
Catch ex As Exception
Return encrypted
End Try
End Function