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.1.5.tar.gz (15.9 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.1.5-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for sparrowencryptiondecryption-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0c98d7c6ccad7cef3f503cf02a3161a56d83f96ab807635e890903acde01f4a6
MD5 98c891d4dc0e49ab91311bccc1d4f166
BLAKE2b-256 dcc431f431d8de9a51dfed5605e8be2d77e070aaef226de48f005a1c0df884a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sparrowencryptiondecryption-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 aaf1ece7255068c3c4aa4ecd8cd0e703747d402e3685dc5e28a7ed5c72ab21a1
MD5 109b92dfec68d33154f47a62f530e0bc
BLAKE2b-256 3756f20ebc610ae26917454631e62f63f7197dcf25f5f67467b6abe4e93363d7

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