Skip to main content

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

Project description

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加解密支持。

Project details


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

If you're not sure about the file name format, learn more about wheel file names.

corecipher-0.1.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

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

Hashes for corecipher-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7bc961da6d968fe00487506bf942b89813ff517e42ada795158c76b443fda7f
MD5 906b15d54d8154e0c08b35d76a9df520
BLAKE2b-256 ecd49d3e1ad1c5434bf37ba4c30d651b32784a7482d13eae24ecc5604177d86d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page