Skip to content
This repository was archived by the owner on May 20, 2022. It is now read-only.

Commit bef9067

Browse files
committed
feat: md5 and sha
1 parent 99bfb9a commit bef9067

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

demo-basis/builtin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import argparse
44
import base64
5+
import hashlib
6+
import hmac
57
import os
68
from collections import ChainMap
79
from collections import Counter
@@ -71,3 +73,13 @@
7173
print(b)
7274
print(base64.decodebytes(b))
7375
print(base64.urlsafe_b64encode(b'/user?name=guest'))
76+
77+
# ===================================================加密==================================================
78+
79+
md5 = hashlib.md5()
80+
md5.update('how to use md5 in python hashlib?'.encode('utf-8'))
81+
print(md5.hexdigest())
82+
sha2 = hashlib.sha256()
83+
sha2.update('test sha256'.encode('utf-8'))
84+
print(sha2.hexdigest())
85+
print(hmac.new(b'salt', b'hello dear', digestmod='md5').hexdigest())

0 commit comments

Comments
 (0)