C # encryption and decryption (Information Security) code encapsulation,
- MD5 hash algorithm (individual encryption)
- The System. Security. Cryptography namespace must be introduced.
/// <Summary> /// function: MD5 hash algorithm /// </summary> /// <param name = "inputStr"> parameter: string to be encrypted </param> /// <param name = "secString"> parameter: Special encryption string </param> /// <returns> return value: encrypted ciphertext (uppercase), string type </returns> public static string GetMd5Str (string inputStr, string secString) {byte [] palinData = null; byte [] encryptData = null; try {MD5 md5 = new MD5CryptoServiceProvider (); palinData = Encoding. default. getBytes (inputStr + secString); encryptData = md5.ComputeHash (palinData);} catch (Exception e) {throw e;} return Convert. toBase64String (encryptData ). substring (0, 20 ). toUpper ();}