軟件功能:可用來加密任何文本,只要別人不知道你的密碼,基本上他是暴力破解不了的,所以呀,機(jī)器上那些想保密的東西都用來加密吧,嘎嘎
Web版地址:http://www./Tools/AES/Default.aspx
AES高級加密標(biāo)準(zhǔn) 密碼學(xué)中的高級加密標(biāo)準(zhǔn),是美國聯(lián)邦政府采用的一種區(qū)塊加密標(biāo)準(zhǔn)。
主要代碼:
- using System;
- using System.Text;
- using System.Security.Cryptography;
- using System.IO;
-
- namespace YongFa365.Security
- {
-
-
-
- public class AES
- {
- public static string Encrypt(string strEncrypt, string strKey)
- {
- try
- {
- byte[] keyArray = UTF8Encoding.UTF8.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strKey, "md5"));
- byte[] strEncryptArray = UTF8Encoding.UTF8.GetBytes(strEncrypt);
- byte[] resultArray = null;
-
- using (RijndaelManaged rDel = new RijndaelManaged())
- {
- rDel.Key = keyArray;
- rDel.Mode = CipherMode.ECB;
- rDel.Padding = PaddingMode.PKCS7;
-
- ICryptoTransform cTransform = rDel.CreateEncryptor();
-
- resultArray = cTransform.TransformFinalBlock(strEncryptArray, 0, strEncryptArray.Length);
-
- }
- return Convert.ToBase64String(resultArray, 0, resultArray.Length);
- }
- catch
- {
- return null;
- }
- }
-
- public static string Decrypt(string strDecrypt, string strKey)
- {
- try
- {
- byte[] keyArray = UTF8Encoding.UTF8.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strKey, "md5"));
- byte[] strDecryptArray = Convert.FromBase64String(strDecrypt);
- byte[] resultArray = null;
-
- using (RijndaelManaged rDel = new RijndaelManaged())
- {
- rDel.Key = keyArray;
- rDel.Mode = CipherMode.ECB;
- rDel.Padding = PaddingMode.PKCS7;
-
- ICryptoTransform cTransform = rDel.CreateDecryptor();
- resultArray = cTransform.TransformFinalBlock(strDecryptArray, 0, strDecryptArray.Length);
-
- }
-
- return UTF8Encoding.UTF8.GetString(resultArray);
- }
- catch
- {
-
- return null;
- }
- }
-
-
- }
- }
相關(guān)類及Demo下載地址:AES加密解密.rar
類來源:http://www./2008/04/17/simple-aes-rijndael-c-encrypt-decrypt-functions/
|