Zaid Iqbal
Zaid Iqbal

Reputation: 1682

Convert 'String' to Base64 encode of MD5 'String' in c# .net

How can i Convert my password 'String' to Base64 encode of MD5 'String'. Like this string 'password' to 'X03MO1qnZdYdgyfeuILPmQ=='.

Please help me here

OR just let me know the technique that how can i convert this 'password' to 'X03MO1qnZdYdgyfeuILPmQ=='. i will code it myself

Upvotes: 4

Views: 8012

Answers (1)

nelek
nelek

Reputation: 4312

Ok, there is example (vb.net, I'll try to convert in c# using some online converter) :

Dim pwd As String = "password"
Dim hs As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create
Dim db As Byte() = hs.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pwd))
Dim result As String = Convert.ToBase64String(db)

string password will result with X03MO1qnZdYdgyfeuILPmQ==

Update : converted to c# using online converter (I hope it's correctly converted)

string pwd = "password";
System.Security.Cryptography.MD5 hs = System.Security.Cryptography.MD5.Create;
byte[] db = hs.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pwd));
string result = Convert.ToBase64String(db);

Upvotes: 8

Related Questions