This commit is contained in:
guanjihuan 2023-09-29 02:34:46 +08:00
parent 8359d41873
commit 76ab237717
4 changed files with 27 additions and 3 deletions

View File

@ -494,6 +494,12 @@ hex = guan.rgb_to_hex(rgb, pound=1)
# 将HEX转成RGB
rgb = guan.hex_to_rgb(hex)
# 使用MD5进行散列加密
hashed_password = guan.encryption_MD5(password, salt='')
# 使用SHA-256进行散列加密
hashed_password = guan.encryption_SHA_256(password, salt='')
# Module 13: file processing

View File

@ -1,7 +1,7 @@
[metadata]
# replace with your username:
name = guan
version = 0.0.176
version = 0.0.177
author = guanjihuan
author_email = guanjihuan@163.com
description = An open source python package

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: guan
Version: 0.0.176
Version: 0.0.177
Summary: An open source python package
Home-page: https://py.guanjihuan.com
Author: guanjihuan

View File

@ -2,7 +2,7 @@
# With this package, you can calculate band structures, density of states, quantum transport and topological invariant of tight-binding models by invoking the functions you need. Other frequently used functions are also integrated in this package, such as file reading/writing, figure plotting, data processing.
# The current version is guan-0.0.176, updated on September 14, 2023.
# The current version is guan-0.0.177, updated on September 29, 2023.
# Installation: pip install --upgrade guan
@ -2858,6 +2858,24 @@ def hex_to_rgb(hex):
length = len(hex)
return tuple(int(hex[i:i+length//3], 16) for i in range(0, length, length//3))
# 使用MD5进行散列加密
def encryption_MD5(password, salt=''):
import hashlib
password = salt+password
hashed_password = hashlib.md5(password.encode()).hexdigest()
return hashed_password
# 使用SHA-256进行散列加密
def encryption_SHA_256(password, salt=''):
import hashlib
password = salt+password
print(password)
hashed_password = hashlib.sha256(password.encode()).hexdigest()
return hashed_password