The source code to encrypt the password
Users. PASSWD = Decryption.encryptdes (getmd5str (_httpreuqeststring["Passwd"]. ToString ()), Commonhelper.getappsettings ("pagepwd"));
/// <summary> ///MD5 16-bit encryption password is lowercase/// </summary> /// <param name= "convertstring" ></param> /// <returns></returns> Public Static stringGETMD5STR (stringconvertstring) {System.Security.Cryptography.MD5CryptoServiceProvider MD5=NewSystem.Security.Cryptography.MD5CryptoServiceProvider (); stringT2 = bitconverter.tostring (Md5.computehash (UTF8Encoding.Default.GetBytes (convertstring)),4,8); T2= T2. Replace ("-",""); T2=T2. ToLower (); returnT2; }
Des encryption and decryption method
//default key Vector Private Static byte[] Keys = {0xEF,0xAB,0x56,0x78,0x90,0x34,0xCD,0x12 }; /// <summary> ///des encrypted String/// </summary> /// <param name= "encryptstring" >string to encrypt</param> /// <param name= "Encryptkey" >encryption key, required for 8-bit</param> /// <returns>encryption successfully returns the encrypted string, failed to return the source string</returns> Public Static stringEncryptdes (stringEncryptString,stringEncryptkey) { Try { byte[] RgbKey = Encoding.UTF8.GetBytes (encryptkey.substring (0,8)); byte[] Rgbiv =Keys; byte[] Inputbytearray =Encoding.UTF8.GetBytes (encryptstring); DESCryptoServiceProvider DCSP=NewDESCryptoServiceProvider (); MemoryStream Mstream=NewMemoryStream (); CryptoStream Cstream=NewCryptoStream (Mstream, Dcsp.createencryptor (RgbKey, Rgbiv), cryptostreammode.write); Cstream.write (Inputbytearray,0, inputbytearray.length); Cstream.flushfinalblock (); returnconvert.tobase64string (Mstream.toarray ()); } Catch { returnencryptstring; } } /// <summary> ///des decryption String/// </summary> /// <param name= "decryptstring" >string to decrypt</param> /// <param name= "Decryptkey" >Decryption key, required to be 8-bit, same as encryption key</param> /// <returns>decryption succeeded in returning the decrypted string, failed to return the source string</returns> Public Static stringDecryptdes (stringDecryptstring,stringDecryptkey) { Try { byte[] RgbKey = Encoding.UTF8.GetBytes (decryptkey.substring (0,8)); byte[] Rgbiv =Keys; byte[] Inputbytearray =convert.frombase64string (decryptstring); DESCryptoServiceProvider DCSP=NewDESCryptoServiceProvider (); MemoryStream Mstream=NewMemoryStream (); CryptoStream Cstream=NewCryptoStream (Mstream, DCSP. CreateDecryptor (RgbKey, Rgbiv), cryptostreammode.write); Cstream.write (Inputbytearray,0, inputbytearray.length); Cstream.flushfinalblock (); returnEncoding.UTF8.GetString (Mstream.toarray ()); } Catch { returndecryptstring; } }
Password encryption method