基于进制转换、随机抽取与压缩算法的浅加密工具
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
- random_encryption
- full_random_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")
random_encryption
- 使用random_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.random_encryption("test", "test")
full_random_encryption
- 使用full_random_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.full_random_encryption("test", "test")
解密
- sparrowEncryptionDecryption的解密方法
- 一个又两种方法
- order_decryption
- easy_decryption
- random_decryption
- full_random_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")
random_decryption
- 使用random_decryption方法解密数据
- 携带两个参数
- decompression: 需要被解密的数据
- key: 秘钥(二进制秘钥)
- 返回被解密的数据或秘钥错误类型
from sparrowEncryptionDecryption import SparrowEncryptionDecryption
sed = SparrowEncryptionDecryption()
sed.random_decryption("test", b"test")
full_random_decryption
- 使用full_random_decryption方法解密数据
- 携带两个参数
- decompression: 需要被解密的数据
- key: 秘钥(二进制秘钥)
- 返回被解密的数据或秘钥错误类型
from sparrowEncryptionDecryption import SparrowEncryptionDecryption
sed = SparrowEncryptionDecryption()
sed.full_random_decryption("test", b"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: 需要被压缩或解压的数据
- 返回被压缩或解压的数据
shuffle_by_seed
- 根据输入字符串作为种子打乱数组
- 携带两个参数
- input_string: 用于生成随机种子的字符串
- array: 需要被打乱的数组
- 打乱后的新数组
get_random_key
- 生成随机密钥对
- 携带两个参数
- keys: 秘钥键
- values: 秘钥值
choice_key
- 获取指定数组中指定数量的随机值
- 携带两个参数
- key_list: 指定数组
- length: 指定数量
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 Distribution
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 sparrowencryptiondecryption-0.4.1.tar.gz.
File metadata
- Download URL: sparrowencryptiondecryption-0.4.1.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a3b50bb15184277625bab6f1b96511d94536138a11e0b85e68cfa28f004fbae
|
|
| MD5 |
a7cec051a5e1a36b9b97ccd0f9818d46
|
|
| BLAKE2b-256 |
f6dca52d69e9e4fe30f0c97fe0b6d4b7a6953f377951cbc57c4894c8f6f61ce5
|
File details
Details for the file sparrowencryptiondecryption-0.4.1-py3-none-any.whl.
File metadata
- Download URL: sparrowencryptiondecryption-0.4.1-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9f740dcfa26133587537e33f1aab14e24c13fa0e44ad839144ce38c92ea8e7c
|
|
| MD5 |
245fcdb9148f1f62488632309017a8fc
|
|
| BLAKE2b-256 |
f5c16c6a1b557f0bac6c2b94aea5e0b216d3e717803eb73ed634b653dcb3a328
|