encrypt basic openssl
Project description
random_encrypt
基于openssl加密
仅使用了 AES-128-CBC
根据时间戳所在的时间区间,时区信息计算加密的key,iv
为每个key设置有效时间(默认5秒,冗余2秒),在不同的时间区间(左包右闭),相同文本加密后的字符串不同
默认时区为东八区,加密端和解密端通过统一时区对齐时间,避免不同时区,同时间段,加密后的密文不同,导致无法解密
在使用时,必须自定义盐值,不能为空。
if self._salt == "":
raise Exception('the salt can not be empty.')
Encrypt函数返回 (加密后字符串,key,iv,加密时使用的时间戳) 供解密失败后备查。
Install
pip install random_tool
示例代码:
from random_encrypt import RandomEncrypt
if __name__ == '__main__':
e = RandomEncrypt({"salt": "salt"})
s = e.encrypt("hello world")
print(s)
t = e.decrypt(s[0])
print(t)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
random_tool-1.0.2.tar.gz
(7.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file random_tool-1.0.2.tar.gz.
File metadata
- Download URL: random_tool-1.0.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1a889af55fe0a40bc30373ef0aa2c1de75d88fd4a005c4279f9d298ba4cbda6
|
|
| MD5 |
8ff1e5cb385d088d9fe4ddc2c5438c2e
|
|
| BLAKE2b-256 |
e1416f151774b48a535a1d61887686ddf40e0b3af3fc4d67020d90cf036322a3
|
File details
Details for the file random_tool-1.0.2-py3-none-any.whl.
File metadata
- Download URL: random_tool-1.0.2-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f50100cad09fec0d42088055ef600898e714921d5a7e98aa82110b610d2d93e8
|
|
| MD5 |
fac65dea8b37c780994bad309111cb53
|
|
| BLAKE2b-256 |
93c59aaba2a630b701b6aaf640f28d8846ccfdec20c1675ca2c6851cf06ca07b
|