Skip to main content

corecipher

加解密工具基础包。提供AES/RSA等加解密方式。

安装

pip install corecipher

加密过程

  1. 使用data_encoder(内容编解码器)对原始数据进行编码,得到bytes类型的原始数据。
    • 默认使用Utf8DataEncoder编解码器。
    • 要求原始数据为可以utf8编码的字符串类型。
  2. 对bytes类型的原始数据进行加密,得到bytes类型的加密结果。
  3. 对bytes类型的加密结果,使用result_encoder(结果编解码器)进行编码,得到最终的结果。
    • 默认使用Base64ResultEncoder编解码器。
    • 最终结果一般为str类型。

解密过程

  1. 使用result_encoder进行解码。
  2. 进行解密操作。
  3. 使用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加解密支持。

Release files for corecipher 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for corecipher 0.1.0
File Interpreter ABI Platform
corecipher-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / corecipher-0.1.0-py3-none-any.whl

Download URL corecipher-0.1.0-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7bc961da6d968fe00487506bf942b89813ff517e42ada795158c76b443fda7f
BLAKE2b-256 checksum
How to use checksums
ecd49d3e1ad1c5434bf37ba4c30d651b32784a7482d13eae24ecc5604177d86d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page