【Kata Daily 190929】Password Hashes(密码哈希)

题目:

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.网址:yii666.com

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文章来源地址:https://www.yii666.com/article/764237.html

passHash("password") // --> "5f4dcc3b5aa765d61d8327deb882cf99"
passHash("abc123") // --> "e99a18c428cb38d5f260853678922e03"

If you want to externally test a string, look at this website.文章来源地址https://www.yii666.com/article/764237.html


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.文章地址https://www.yii666.com/article/764237.html

解题办法:

import hashlib
def pass_hash(str):
return hashlib.md5(str.encode()).hexdigest()

知识点:

1、使用哈希的办法,先导入hashlib,再使用hashlib.md5(str.encode()).hexdigest()网址:yii666.com<

版权声明:本文内容来源于网络,版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。文本页已经标记具体来源原文地址,请点击原文查看来源网址,站内文章以及资源内容站长不承诺其正确性,如侵犯了您的权益,请联系站长如有侵权请联系站长,将立刻删除

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信图片_20190322181744_03.jpg

微信扫一扫打赏

请作者喝杯咖啡吧~

支付宝扫一扫领取红包,优惠每天领

二维码1

zhifubaohongbao.png

二维码2

zhifubaohongbao2.png