Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the hash_md5 encryption method of C# and Python

Shulou Source: shulou.com Published: 2022-06-02 16:41:19 10月10日 Update

This article introduces what is the hash_md5 encryption method of C# and Python. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

1. Hash_md5 encryption of C# and Python 1, C# version 1public static string GenerateMD5Hash (string str) {MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider (); byte [] byteArray = Encoding.UTF8.GetBytes (str); byteArray = md5.ComputeHash (byteArray); string hashedValue = ""; foreach (byte b in byteArray) {hashedValue + = b.ToString ("x2") } return hashedValue;} 2, C # version 2 public static string GenerateMD5Hash (string str) {MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider (); byte [] byteArray = Encoding.UTF8.GetBytes (str); byteArray = md5.ComputeHash (byteArray); StringBuilder mdStrBuff = new StringBuilder (); for (int I = 0; I < byteArray.Length If ((0xFF & byteArray [I]) .ToString ("x"). Length = = 1) {mdStrBuff.Append ("0");} mdStrBuff.Append ((0xFF & byteArray [I]) .ToString ("x"));} string r = mdStrBuff.ToString () Return r;} 3, Python version def hash_md5 (s): res = sh = hashlib.md5 () h.update (res.encode (encoding='utf-8')) return h.hexdigest () about what the hash_md5 encryption methods of C# and Python are, I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Caching encryption version method content more help good interest guys buddies articles knowledge articles references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Xiaomi Docker Redmi