- MD5 hashing Algorithm (single encryption)
- The System.Security.Cryptography namespace must be introduced
/// <summary> ///function: MD5 hashing algorithm/// </summary> /// <param name= "Inputstr" >parameters: String to encrypt</param> /// <param name= "secstring" >Parameters: Special Cryptographic strings</param> /// <returns>return value: Ciphertext (uppercase) after encryption, string type</returns> Public Static stringGETMD5STR (stringINPUTSTR,stringsecstring) { byte[] Palindata =NULL; byte[] EncryptData =NULL; Try{MD5 MD5=NewMD5CryptoServiceProvider (); Palindata= Encoding.Default.GetBytes (Inputstr +secstring); EncryptData=Md5.computehash (Palindata); } Catch(Exception e) {Throwe; } returnConvert.tobase64string (EncryptData). Substring (0, -). ToUpper (); }
C # Encryption and decryption (information security) Code encapsulation