Explorar el Código

添加sha1密文摘要

dongzhaorui@topnet.net.cn hace 3 años
padre
commit
7029d79b81
Se han modificado 1 ficheros con 13 adiciones y 0 borrados
  1. 13 0
      zbytb/utils/tools.py

+ 13 - 0
zbytb/utils/tools.py

@@ -1,6 +1,19 @@
+import hashlib
 import socket
 
 
+def sha1(text: str):
+    """
+    十六进制数字字符串形式摘要值
+
+    @param text: 字符串文本
+    @return: 摘要值
+    """
+    _sha1 = hashlib.sha1()
+    _sha1.update(text.encode("utf-8"))
+    return _sha1.hexdigest()
+
+
 def get_host_ip():
     s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     try: