加解密工具基础包。提供AES/RSA等加解密方式。
Project description
corecipher
加解密工具基础包。提供AES/RSA等加解密方式。
安装
pip install corecipher
加密过程
- 使用
data_encoder(内容编解码器)对原始数据进行编码,得到bytes类型的原始数据。- 默认使用
Utf8DataEncoder编解码器。 - 要求原始数据为可以utf8编码的字符串类型。
- 默认使用
- 对
bytes类型的原始数据进行加密,得到bytes类型的加密结果。 - 对
bytes类型的加密结果,使用result_encoder(结果编解码器)进行编码,得到最终的结果。- 默认使用
Base64ResultEncoder编解码器。 - 最终结果一般为
str类型。
- 默认使用
解密过程
- 使用
result_encoder进行解码。 - 进行解密操作。
- 使用
data_encoder进行解码。
支持的内容编解码器
- RawDataEncoder
- Utf8DataEncoder
- Gb18030DataEncoder
- JsonEncoder
- PickleEncoder
- MarshalEncoder
- MsgPackEncoder
支持的结果编解码器
- RawResultEncoder
- Utf8ResultEncoder
- Base64ResultEncoder
- URLSafeBase64ResultEncoder
- HexlifyResultEncoder
支持的加解密方式
AES加解密
- GCMAESCipher
- CTRAESCipher
- ECBAESCipher
- MysqlCompatibleAESCipher
RSA加解密
- RSACipher
RSA+AES加解密
- RESCipher
密码表加解密
- M1Cipher
- M2Cipher
- M12Cipher
- S1Cipher
- S12Cipher
- IvCipher
- IvfCipher
使用方法
AES GCM模式加解密
import corecipher
gen = corecipher.GCMAESCipher(password="hello")
data1 = "hello"
data2 = gen.encrypt(data1)
data3 = gen.decrypt(data2)
assert data1 == data3
AES CTR模式加解密
import corecipher
gen = corecipher.CTRAESCipher(password="hello")
data1 = "hello"
data2 = gen.encrypt(data1)
data3 = gen.decrypt(data2)
assert data1 == data3
AES ECB模式加解密
import corecipher
gen = corecipher.ECBAESCipher(password="hello")
data1 = "hello"
data2 = gen.encrypt(data1)
data3 = gen.decrypt(data2)
assert data1 == data3
版本记录
v0.1.0
- 版本首发。
- 添加RSA/AES加解密支持。
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 corecipher-0.1.0-py3-none-any.whl.
File metadata
- Download URL: corecipher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7bc961da6d968fe00487506bf942b89813ff517e42ada795158c76b443fda7f
|
|
| MD5 |
906b15d54d8154e0c08b35d76a9df520
|
|
| BLAKE2b-256 |
ecd49d3e1ad1c5434bf37ba4c30d651b32784a7482d13eae24ecc5604177d86d
|