kiranboi
asked on
Encrypting / Decrypting String Data
Hi all,
I have found on another post the following code to encrypt a string:
Public Function encrypt(ByVal myString As String) As String
Dim clearBytes As Byte() = New UnicodeEncoding().GetBytes (myString)
Dim myhash As HashAlgorithm = CryptoConfig.CreateFromNam e("MD5")
Dim hashedBytes As Byte() = myhash.ComputeHash(clearBy tes)
Return BitConverter.ToString(hash edBytes)
End Function
This works great but I need the function to decrypt the data and return it to its orignal string form. Also what namespace is UnicodeEncoding in?
I have found on another post the following code to encrypt a string:
Public Function encrypt(ByVal myString As String) As String
Dim clearBytes As Byte() = New UnicodeEncoding().GetBytes
Dim myhash As HashAlgorithm = CryptoConfig.CreateFromNam
Dim hashedBytes As Byte() = myhash.ComputeHash(clearBy
Return BitConverter.ToString(hash
End Function
This works great but I need the function to decrypt the data and return it to its orignal string form. Also what namespace is UnicodeEncoding in?
Hash functions are not reversible. You need to pick something like the RijndaelCryptoServiceProvi der from System.Security.Cryptograp hy.
ASKER
sounds good. any chance of a code example
I can give you mine in C#, but will have to search a bit to find some in Basic.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.