Link to home
Start Free TrialLog in
Avatar of kiranboi
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.CreateFromName("MD5")
        Dim hashedBytes As Byte() = myhash.ComputeHash(clearBytes)
        Return BitConverter.ToString(hashedBytes)
    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?
Avatar of JimBrandley
JimBrandley
Flag of United States of America image

Hash functions are not reversible. You need to pick something like the RijndaelCryptoServiceProvider from System.Security.Cryptography.
Avatar of kiranboi
kiranboi

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
Avatar of JimBrandley
JimBrandley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial