C#各种加密方法封装类,软创加密类,内含MD5加密解密、DES法解密加密、RC2加密解密、3DES加密解密,还有AES加解密等,使用时用到哪一种加密方法,可把代码单独摘录出来,本类比较综合,代码中包括注释,完整代码:viewsourceprint?001usingSystem;;;;;{008///009///软创加密类010///lassCryptography012{013///014///MD5加密,静态方法015///016///待加密的密文017///returns018publicstaticstringMD5Encrypt(stringEncryptString)019{020if((EncryptString)){throw(newException(" 密文不得为空"));}021MD5m_ClassMD5=newMD5CryptoServiceProvider();022stringm_strEncrypt="";023try024{025 m_strEncrypt =(puteHash((EncryptString))).Replace("-","");026}027catch(ArgumentExceptionex){throwex;}028catch(CryptographicExceptionex){throwex;}029catch(Exceptionex){throwex;}030finally{();}031returnm_strEncrypt;032}033///034///DES加密(数据加密标准,速度较快,适用于加密大量数据的场合 )035///036///待加密的密文037///加密的密钥038IIIreturns039publicstaticstringDESEncrypt(stringEncryptString,stringEncryptKey)040(041if((EncryptString))(throw(newException(" 密文不得为空"));}042if((EncryptKey))(throw(newException("密钥不得为空"));}043if(!=8)(throw(newException("密钥必须为8位"));}044byte[]m_btIV=(0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF};045stringm_strEncrypt="";046DESCryptoServiceProviderm_DESProvider=newDESCryptoServiceProvider();047
C#MD5加密解密DESRC23DESAES等软创加密类 来自淘豆网www.taodocs.com转载请标明出处.