Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the hash_md5 encryption method of C# and Python

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report