数据加密之RijndaelManaged加密

 #region RijndaelManaged加密
/// <summary>
/// 加密数据
/// </summary>
/// <param name="Text">要加密的内容</param>
/// <param name="sKey">key,必须为32位</param>
/// <returns></returns>
public static string RiEncrypt(string Text, string sKey)
{
byte[] keyArray = UTF8Encoding.UTF8.GetBytes(sKey);
//TripleDESCryptoServiceProvider
RijndaelManaged encryption = new RijndaelManaged();
encryption.Key = keyArray; encryption.Mode = CipherMode.ECB; encryption.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = encryption.CreateEncryptor(); byte[] _EncryptArray = UTF8Encoding.UTF8.GetBytes(Text); byte[] resultArray = cTransform.TransformFinalBlock(_EncryptArray, , _EncryptArray.Length); return Convert.ToBase64String(resultArray, , resultArray.Length); }
#endregion
#region =======RijndaelManaged解密========
/// <summary>
/// 解密数据
/// </summary>
/// <param name="Text"></param>
/// <param name="sKey"></param>
/// <returns></returns>
public static string RiDecrypt(string Text, string sKey)
{
byte[] keyArray = UTF8Encoding.UTF8.GetBytes(sKey); RijndaelManaged decipher = new RijndaelManaged(); decipher.Key = keyArray; decipher.Mode = CipherMode.ECB; decipher.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = decipher.CreateDecryptor(); byte[] _EncryptArray = Convert.FromBase64String(Text); byte[] resultArray = cTransform.TransformFinalBlock(_EncryptArray, , _EncryptArray.Length); return UTF8Encoding.UTF8.GetString(resultArray); }
#endregion
上一篇:MySQL高级第四章——MySQL的锁机制


下一篇:实现一个simple 3层的神经网络