标签:hashlib hash str Daily will 哈希 Kata password md5
题目:
When you sign up for an account somewhere, some websites do not actually store your password in their databases. Instead, they will transform your password into something else using a cryptographic hashing algorithm.
After the password is transformed, it is then called a password hash. Whenever you try to login, the website will transform the password you tried using the same hashing algorithm and simply see if the password hashes are the same.
Create the function that converts a given string into an md5
hash. The return value should be encoded in hexadecimal
.
Code Examples
passHash("password") // --> "5f4dcc3b5aa765d61d8327deb882cf99"
passHash("abc123") // --> "e99a18c428cb38d5f260853678922e03"
If you want to externally test a string, look at this website.
As a side note, md5
can be exploited, so never use it for anything secure. The reason I used it in this kata is simply because it is a very common hashing algorithm and many people will recognize the name.
解题办法:
import hashlib def pass_hash(str): return hashlib.md5(str.encode()).hexdigest()
知识点:
1、使用哈希的办法,先导入hashlib,再使用hashlib.md5(str.encode()).hexdigest()
标签:hashlib,hash,str,Daily,will,哈希,Kata,password,md5 来源: https://www.cnblogs.com/bcaixl/p/11606098.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。