c# ile md5 şifreleme ve şifre çözme

Описание к видео c# ile md5 şifreleme ve şifre çözme

public static class sifrelecoz
{
public static string sifrele(string sifre, string hash)
{
byte[] data = UTF8Encoding.UTF8.GetBytes(sifre);
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
{
byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
using (TripleDESCryptoServiceProvider tripDes = new TripleDESCryptoServiceProvider() { Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 })
{
ICryptoTransform transform = tripDes.CreateEncryptor();
byte[] results = transform.TransformFinalBlock(data, 0, data.Length);
return Convert.ToBase64String(results, 0, results.Length);
}
}
}
public static string coz(string SifrelenmisDeger, string hash)
{
try
{
byte[] data = Convert.FromBase64String(SifrelenmisDeger);
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
{
byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
using (TripleDESCryptoServiceProvider tripDes = new TripleDESCryptoServiceProvider() { Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 })
{

ICryptoTransform transform = tripDes.CreateDecryptor();
byte[] results = transform.TransformFinalBlock(data, 0, data.Length);
return UTF8Encoding.UTF8.GetString(results);


}
}
}
catch
{
return SifrelenmisDeger;
}
}
}

Комментарии

Информация по комментариям в разработке