Posted By

jags_sonawane on 02/13/08



Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Encryption of string

 / Published in: C#

  1. public static byte[] encryptData(string data)
  2. {
  3. System.Security.Cryptography.MD5CryptoServiceProvider md5Hasher = new System.Security.Cryptography.MD5CryptoServiceProvider();
  4. byte[] hashedBytes;
  5. System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
  6. hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(data));
  7. return hashedBytes;
  8. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: AndrewVos on April 16, 2008

This is hashing not encryption. There's no way to get the string back.

You could use: System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"md5") if you just want to hash a password.

You need to login to post a comment.