当前位置:首页 >> 电力/水利 >>

MD5解密加密


// ?? ??: ??????????????×÷?à???á????????????×÷???ù?????? using System; using System.IO; using System.Text; using System.Security.Cryptography; namespace CClassLibrary.Rule { /// <summary&g

t; /// CCryptography ?????????÷?? /// </summary> public class CCryptography { /// <summary> /// ??·¨???ú?????? /// </summary> protected string mstrv_CryptKey ="!@#$%+|+)!#$%!@#adfasdf)89083049123)(*&^@#$%@#$%"; /// <summary> /// ??·¨?????????ò?? /// </summary> protected string mstrv_CryptIV = "!@adff2324gfh)asdf12dfasdf)89083049123)(*&^@#$%@#$%"; //================================================================ =================================== // 2006-11-28 megan ???? /// <summary> /// ?????é?¤??·¨???ú?????? /// </summary> protected string mstrv_SecdCryptKey ="!@#$%+|+)!#$%!@#asdfasdf)123456456)(*&^@#$%@#$%"; /// <summary> /// ?????é?¤??·¨?????????ò?? /// </summary> protected string mstrv_SecdCryptIV = "!@adff2324gfh)adfasfsdfa3)1234567487)(*&^@#$%@#$%"; //================================================================ =================================== /// <summary> /// ??????????????×÷?à /// </summary>

public CCryptography() { mstrv_CryptKey = "!@#$%+|+)!#$%!@#adfasdf)89083049123)(*&^@#$%@#$%".Substring(0,32) ; mstrv_CryptIV = "!@adff2324gfh)asdf12dfasdf)89083049123)(*&^@#$%@#$%".Substring(0, 16); } #region [Encrypt,Decrypt] public function //·?·¨ //????·?·¨ /// <summary> /// ????·?·¨ /// </summary> /// <param name="sCryptText"></param> /// <param name="sCryptKey"></param> /// <param name="sCryptIV"></param> /// <returns></returns> public string Encrypt( string sCryptText, sCryptKey,string sCryptIV) { RijndaelManaged des = new RijndaelManaged(); //°?×?·???·???byte??×é?? //?-????????UTF8±à??????????Unicode±à?????????? byte[] inputByteArray Encoding.Default.GetBytes(sCryptText); //byte[] inputByteArray=Encoding.Unicode.GetBytes(pToEncrypt);

string

=

//?¨?????????ó?????????????? //?-??????ASCIIEncoding.ASCII·?·¨??GetBytes·?·¨ //????????????±?????????????±? des.Key = ASCIIEncoding.ASCII.GetBytes(sCryptKey); des.IV = ASCIIEncoding.ASCII.GetBytes(sCryptIV); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(),CryptoStreamMode.Write); //Write the byte array into the crypto stream //(It will end up in the memory stream) cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock();

//Get the data back from the memory stream, and into a string StringBuilder ret = new StringBuilder(); foreach(byte b in ms.ToArray()) { //Format as hex ret.AppendFormat("{0:X2}", b); } ret.ToString(); return ret.ToString(); } //????·?·¨ public string Decrypt(string sCryptText, sCryptKey,string sCryptIV) { RijndaelManaged des = new RijndaelManaged();

string

//Put the input string into the byte array byte[] inputByteArray = new byte[sCryptText.Length / 2]; for(int x = 0; x < sCryptText.Length / 2; x++) { int i = (Convert.ToInt32(sCryptText.Substring(x * 2, 2), 16)); inputByteArray[x] = (byte)i; } //?¨?????????ó?????????????????????????????????? des.Key = ASCIIEncoding.ASCII.GetBytes(sCryptKey); des.IV = ASCIIEncoding.ASCII.GetBytes(sCryptIV); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(),CryptoStreamMode.Write); //Flush the data through the crypto stream into the memory stream cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); //Get the decrypted data back from the memory stream //?¨??StringBuild???ó??CreateDecrypt?????????÷???ó??±???°?????? ó????±?±????÷???ó StringBuilder ret = new StringBuilder(); return

System.Text.Encoding.Default.GetString(ms.ToArray()); } #endregion #region [Encrypt,Decrypt] satatic function /// <summary> /// ×?·??????? /// </summary> /// <param name="sCryptText">?è?????????-×?·???</param> /// <returns>?????ó??×?·???</returns> public static string Encrypt( string sCryptText ) { CCryptography csCrypt = new CCryptography(); return csCrypt.Encrypt(sCryptText,csCrypt.mstrv_CryptKey,csCrypt.mstrv_Cr yptIV ); } /// <summary> /// ×?·??????? /// </summary> /// <param name="sCryptText">?è????????????×?·???</param> /// <returns>?????ó??×?·???</returns> public static string Decrypt( string sCryptText ) { CCryptography csCrypt = new CCryptography(); return csCrypt.Decrypt( sCryptText,csCrypt.mstrv_CryptKey,csCrypt.mstrv_C ryptIV ); } /// <summary> /// ?????é?¤×?·??????? /// </summary> /// <param name="sCryptText">?è?????????-×?·???</param> /// <returns>?????ó??×?·???</returns> public static string SecdEncrypt( string sCryptText ) { CCryptography csCrypt = new CCryptography(); return csCrypt.Encrypt(sCryptText,csCrypt.mstrv_SecdCryptKey,csCrypt.mstr

v_SecdCryptIV ); } /// <summary> /// ?????é?¤×?·??????? /// </summary> /// <param name="sCryptText">?è????????????×?·???</param> /// <returns>?????ó??×?·???</returns> public static string SecdDecrypt( string sCryptText ) { CCryptography csCrypt = new CCryptography(); return csCrypt.Decrypt( sCryptText,csCrypt.mstrv_SecdCryptKey,csCrypt.mst rv_SecdCryptIV ); } #endregion } }


相关文章:
常用的MD5解密和加密后的值
常用的MD5解密加密后的值_IT/计算机_专业资料。常用的MD5解密加密后的值常用的 MD5 解密加密后的值 常用的 MD5 解密 MD5(admin,16) = 7a57a5a743 MD5...
MD5加密解密方法
MD5加密解密方法_计算机软件及应用_IT/计算机_专业资料。MD5加密解密方法asp.net 实现 MD5 加密的方法 asp.net 自带的 md5 加密用下面这种方法,但这种方法只能加密...
MD5加密与解密
MD5加密解密_计算机软件及应用_IT/计算机_专业资料 暂无评价|0人阅读|0次下载|举报文档 MD5加密解密_计算机软件及应用_IT/计算机_专业资料。MD5 加密解密 ...
MD5加密解密类(Java)
MD5加密解密类(Java)_IT/计算机_专业资料。一个上Java培训课时写的MD5加密解密类package com.zyg.security.md5; import import import import import java.io.Un...
MD5加密解密算法的描述
MD5加密解密算法的描述_计算机软件及应用_IT/计算机_专业资料 暂无评价|0人阅读|0次下载|举报文档 MD5加密解密算法的描述_计算机软件及应用_IT/计算机_专业资料。...
加密、解密MD5,SHA等
加密解密MD5,SHA等_其它考试_资格考试/认证_教育专区。加密解密MD5,SHA等加密解密 MD5,SHA 等 密码技术是解决信息网络安全的关键技术, 信息网络安全中的身份...
教你破解40位加密密码的方法
电脑知识应用系列之---电脑知识应用系列之--- 教你破解 40 位加密密码的方法如果遇到 MD5 加密文件,而又不知道密码的。 请在数据库中换上这组加密的数据吧 ...
编写基于MD5算法的加密解密程序
编写基于MD5算法的加密解密程序_工学_高等教育_教育专区。编写基于MD5算法的加密解密程序实验报告集美大学计算机工程学院实验报告课程名称 课程名称:现代密码学 名称 指...
Md5加密算法的原理及应用
Md5 加密算法的原理及应用 1.前言 Md5 的全称是 Message-Digest Algorithm 5(...要解密 MD5 没有现成的算法,只能用穷举法,把可能出现的明 文,用 MD5 算法...
Md5(VavicApp)加密解密
Md5(VavicApp)加密解密_计算机软件及应用_IT/计算机_专业资料。md5加密解密(C#源码) Md5 加密解密 Message Digest Algorithm MD5(中文名为消息摘要算法第五版)为...
更多相关标签:
md5解密 | md5加密 | md5加密算法 | md5解密加密专家 | md5在线加密解密 | c md5加密解密 | java md5加密解密 | java实现md5加密解密 |