标签:向量 rms provider nconf 字符 一个 tor decrypt 解密
//把一个字符串转换成对应的MD5
public static string toMD5(string str)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToLower();
}
public static string _KEY = "wzr17021"; //密钥
public static string _IV = "wzr17022"; //向量
/// <summary>
/// 加密
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static string DES加密(string data)
{
byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(_KEY);
byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(_IV);
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
int i = cryptoProvider.KeySize;
MemoryStream ms = new MemoryStream();
CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateEncryptor(byKey, byIV), CryptoStreamMode.Write);
StreamWriter sw = new StreamWriter(cst);
sw.Write(data);
sw.Flush();
cst.FlushFinalBlock();
sw.Flush();
string strRet = Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
return strRet;
}
/// <summary>
/// 解密
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static string DES解密(string data)
{
byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(_KEY);
byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(_IV);
byte[] byEnc;
try
{
data.Replace("_%_", "/");
data.Replace("-%-", "#");
byEnc = Convert.FromBase64String(data);
}
catch
{
return null;
}
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
MemoryStream ms = new MemoryStream(byEnc);
CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateDecryptor(byKey, byIV), CryptoStreamMode.Read);
StreamReader sr = new StreamReader(cst);
return sr.ReadToEnd();
}
标签:向量 rms provider nconf 字符 一个 tor decrypt 解密
原文地址:https://www.cnblogs.com/feihusurfer/p/9117744.html