C# simple MD5 encryption
Now this is the easiest way to MD5 password :
-
using System;
-
using System.Collections.Generic;
-
using System.Text;
-
using System.Security.Cryptography;
-
-
namespace Net.MedSo.Mooci.Security
-
{
-
public class MD5Encryption : IEncryption
-
{
-
-
private static MD5Encryption md5Encryption;
-
-
// Factory pattern to return only a single
-
// instance of MD5Encryption in the application
-
public static MD5Encryption GetInstance(){
-
if(md5Encryption == null){
-
return new MD5Encryption();
-
}
-
-
return md5Encryption;
-
}
-
-
// Default constructor
-
public MD5Encryption() {
-
}
-
-
/*
-
* Return the encrypted string
-
*/
-
public string GetEncryptedString(string strToEncrypt) {
-
-
MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
-
byte[] data = Encoding.ASCII.GetBytes(strToEncrypt);
-
data = provider.ComputeHash(data);
-
-
return Encoding.ASCII.GetString(data);
-
}
-
}
-
}
Hope this useful.
Thank’s ![]()
Leave a Reply