Skip to main content

基于进制转换与压缩算法的浅加密工具

Project description

sparrowEncryptionDecryption

目录


简介

  • sparrowEncryptionDecryption 加密解密库是一个用于数据加密和解密的 Python 库,支持二进制和四进制两种加密模式,并提供同步和异步接口。

安装

pip install sparrowEncryptionDecryption

入口

  • 导入类方式

主入口

  • 直接从sparrowEncryptionDecryption导入
import sparrowEncryptionDecryption as sed
from sparrowEncryptionDecryption import SparrowEncryptionDecryption
from sparrowEncryptionDecryption import SparrowEncryptionDecryptionAsync

子入口

  • 从sparrowEncryptionDecryption.encryption_decryption导入
from sparrowEncryptionDecryption.encryption_decryption import SparrowEncryption
from sparrowEncryptionDecryption.encryption_decryption import SparrowEncryptionAsync
from sparrowEncryptionDecryption.encryption_decryption import SparrowDecryption
from sparrowEncryptionDecryption.encryption_decryption import SparrowDecryptionAsync
from sparrowEncryptionDecryption.encryption_decryption import SparrowEncryptionDecryption
from sparrowEncryptionDecryption.encryption_decryption import SparrowEncryptionDecryptionAsync

分入口

  • 从sparrowEncryptionDecryption.encryption_decryption.function导入
from sparrowEncryptionDecryption.function.decryption import SparrowDecryption
from sparrowEncryptionDecryption.function.decryption import SparrowDecryptionAsync
from sparrowEncryptionDecryption.function.encryption import SparrowEncryption
from sparrowEncryptionDecryption.function.encryption import SparrowEncryptionAsync

使用

  • sparrowEncryptionDecryption的使用方法
  • sparrowEncryptionDecryption相关类初始化有四个参数,不输入则使用默认秘钥集
    • order_keys1: order方法第一次解密秘钥
    • order_keys2: order方法第二次解密秘钥
    • easy_keys1: easy方法第一次解密秘钥
    • easy_keys2: easy方法第二次解密秘钥

加密

  • sparrowEncryptionDecryption的加密方法
  • 一个有两种方法
    • order_encryption
    • easy_encryption

order_encryption

  • 使用order_encryption方法加密数据
  • 携带五个参数
    • string: 需要被加密的数据
    • key: 秘钥
    • effective_duration: 秘钥过期时间,-1为永不过期,默认-1
    • is_compression: 默认为2,二次压缩压缩,1为一次压缩,0为不压缩
    • mode: 加密模式,0为二进制加密,1为四进制加密,默认为0
    • compression_type: 压缩算法(zlib、gzip、bz2、lzma、lz4、brotli、snappy、huffman、deflate、lz77)
  • 返回被加密好的数据
from sparrowEncryptionDecryption import SparrowEncryptionDecryption

sed = sparrowEncryptionDecryption()
sed.order_encryption("test", "test")

easy_encryption

  • 使用easy_encryption方法加密数据
  • 携带三个参数
    • string: 需要被加密的数据
    • key: 秘钥
    • mode: 加密模式,0为二进制加密,1为四进制加密,默认为0
    • compression_type: 压缩算法(zlib、gzip、bz2、lzma、lz4、brotli、snappy、huffman、deflate、lz77)
  • 返回被加密好的数据
from sparrowEncryptionDecryption import SparrowEncryptionDecryption

sed = sparrowEncryptionDecryption()
sed.easy_encryption("test", "test")

解密

  • sparrowEncryptionDecryption的解密方法
  • 一个又两种方法
    • order_decryption
    • easy_decryption

order_decryption

  • 使用order_decryption方法解密数据
  • 携带两个参数
    • decompression: 需要被解密的数据
    • key: 秘钥
    • compression_type: 压缩算法(zlib、gzip、bz2、lzma、lz4、brotli、snappy、huffman、deflate、lz77)
  • 返回被解密的数据或秘钥错误类型
from sparrowEncryptionDecryption import SparrowEncryptionDecryption

sed = sparrowEncryptionDecryption()
sed.order_decryption("test", "test")

easy_decryption

  • 使用easy_decryption方法解密数据
  • 携带两个参数
    • decompression: 需要被解密的数据
    • key: 秘钥
    • compression_type: 压缩算法(zlib、gzip、bz2、lzma、lz4、brotli、snappy、huffman、deflate、lz77)
  • 返回被解密的数据或秘钥错误类型
from sparrowEncryptionDecryption import SparrowEncryptionDecryption

sed = sparrowEncryptionDecryption()
sed.easy_decryption("test", "test")

工具

  • sparrowEncryptionDecryption涉及使用到的工具方法

binary_to_quaternary

  • 将二进制转换为四进制
  • 携带一个参数
    • binary: 二进制串
  • 返回二进制的四进制数据

quaternary_to_binary

  • 将四进制转换为二进制
  • 携带一个参数
    • quaternary: 四进制串
  • 返回四进制的二进制数据

string_to_binary

  • 将字符串转换为二进制
  • 携带一个参数
    • string: 字符串
  • 返回字符串的二进制数据

binary_to_string

  • 将二进制转换为字符串
  • 携带一个参数
    • binary: 二进制串
  • 返回二进制代表的字符串

split_pairwise

  • 将字符串两两分为一组并存入数组
  • 携带一个参数
    • string: 被分割的字符串
  • 返回分割好的数组

split_double_pairwise

  • 将字符串每四个分为一组并存入数组
  • 携带一个参数
    • string: 被分割的字符串
  • 返回分割好的数组

order_compression_and_decompression2

  • 将加密内容进行二次压缩或解压
  • 携带三个参数
    • keys2: 密钥对
    • mode: True为加密,False为解密,bool类型
    • data: 需要被压缩或解压的数据
  • 返回被压缩或解压的数据

order_compression_and_decompression

  • 将加密内容压缩或解压
  • 携带三个参数
    • keys2: 密钥对
    • mode: True为加密,False为解密,bool类型
    • data: 需要被压缩或解压的数据
  • 返回被压缩或解压的数据

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparrowencryptiondecryption-0.2.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

sparrowencryptiondecryption-0.2.1-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file sparrowencryptiondecryption-0.2.1.tar.gz.

File metadata

File hashes

Hashes for sparrowencryptiondecryption-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b0c7a114b090899898622fb879d5d5ef9986256cae4893a5e54ad237065af907
MD5 4a2c481ae47f91e24131811d09b8bb0f
BLAKE2b-256 abf19e21f23666239e59387d4fb80eeb06ea9a6873a1e1878b9bf944abf7e242

See more details on using hashes here.

File details

Details for the file sparrowencryptiondecryption-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sparrowencryptiondecryption-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca5620d9d4ca28ae5a50cdb8010ce2e8e3a0344c6208f20d0cffa4a64b4fb4f0
MD5 093bd93b4a9bd4d21fb564879dcf2691
BLAKE2b-256 25c4d54006364ec65493b0170ac06455a2064c10f0198fe5d6cc1827556f1ea2

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