public string Decrypt(string pToDecrypt, string sKey)
{
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
byte[] bytes = new PasswordDeriveBytes(sKey, null).GetBytes(8);
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(bytes, bytes), CryptoStreamMode.Write);
try
{
byte[] buffer = Convert.FromBase64String(pToDecrypt);
stream2.Write(buffer, 0, buffer.Length);
stream2.FlushFinalBlock();
byte[] buffer3 = stream.ToArray();
return Encoding.UTF8.GetString(buffer3);
}
catch
{
return "";
}
}
public string Encrypt(string pToEncrypt, string sKey)
{
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
byte[] bytes = new PasswordDeriveBytes(sKey, null).GetBytes(8);
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);
try
{
byte[] buffer = Encoding.UTF8.GetBytes(pToEncrypt);
stream2.Write(buffer, 0, buffer.Length);
stream2.FlushFinalBlock();
return Convert.ToBase64String(stream.ToArray());
}
catch
{
return "";
}
}
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)