Skip to main content

EncroX 官方文档

简介

EncroX是一个强大的加密拓展工具,旨在为您的应用程序和系统提供可靠的加密和解密功能。通过集成各种密码学算法和密钥管理方法,EncroX使您能够轻松地进行数据加密、解密和安全通信。

许可证

EncroX 使用 AGPL-3 开源许可证。请仔细阅读许可证文本以了解使用和分发 EncroX 的限制和义务。您可以在 LICENSE 文件中找到完整的许可证文本。

主要功能

  • 支持生成 ECC(椭圆曲线加密)公钥和私钥对。
  • 支持生成 RSA 公钥和私钥对。
  • 提供基于 RSA 的加密和解密功能,用于保护数据的传输和存储。
  • 提供基于 ECC 的加密和解密功能,用于安全通信和数据保护。
  • 提供基于 AES 的加密和解密功能,用于快速且可靠地加密和解密数据。
  • 提供简单易用的接口,方便集成到您的应用程序和系统中。

使用示例

生成 ECC 密钥对

from EncroX.ecc import generate_ecc_key
private_key, public_key = generate_ecc_keys(curve='256')

生成指定椭圆曲线(可选参数:'256'、'384'、'521')的 ECC 私钥和公钥。

函数签名

def generate_ecc_keys(curve='256') -> Tuple[str, str]:
    """
    使用选定的椭圆曲线生成ECC公钥和私钥对。

    Args:
        curve (str): 指定生成密钥对的椭圆曲线,可选值为 '256'、'384' 和 '521',默认为 '256'。

    Returns:
        tuple: 一个包含私钥PEM和公钥PEM的元组。
    """
    ...

生成 RSA 密钥对

from EncroX.rsa import generate_rsa_keys
private_key, public_key = generate_rsa_keys(bits='2048')

生成指定位数(可选参数:'2048'、'3072'、'4096')的 RSA 私钥和公钥。

函数签名

def generate_rsa_keys(bits='2048') -> Tuple[str, str]:
    """
    生成RSA公钥和私钥对。

    Args:
        bits (str): 指定生成密钥对的位数,可选值为 '2048'、'3072' 和 '4096',默认为 '2048'。

    Returns:
        tuple: 一个包

含私钥PEM和公钥PEM的元组。
    """
    ...

使用 RSA 公钥加密数据

from EncroX.rsa import rsa_encrypt
encrypted_data = rsa_encrypt(data, public_key)

使用 RSA 公钥对数据进行加密,并返回加密后的数据。

函数签名

def rsa_encrypt(data, public_key) -> Union[str, bytes]:
    """
    使用RSA公钥对数据进行加密。

    Args:
        data (str or bytes): 需要加密的数据,数据类型为字符串或字节。
        public_key (str): 用于加密数据的PEM格式RSA公钥。

    Returns:
        str or bytes: 包含加密后的数据和加密后的AES密钥的元组,返回的类型与传入的数据类型相同。
    """
    ...

使用 RSA 私钥解密数据

from EncroX.rsa import rsa_decrypt
decrypted_data = rsa_decrypt(encrypted_data_with_key, private_key)

使用 RSA 私钥解密包含加密数据和加密密钥的数据,并返回解密后的原始数据。

函数签名

def rsa_decrypt(encrypted_data_with_key, private_key) -> Union[str, bytes]:
    """
    使用RSA私钥解密数据。

    Args:
        encrypted_data_with_key (str or bytes): 需要解密的数据,是一个Base64编码过的字符串或字节,其中包含加密后的数据和加密后的AES密钥。
        private_key (str): 用于解密数据的PEM格式RSA私钥。

    Returns:
        str or bytes: 解密后的原始数据,返回的类型与传入的数据类型相同。
    """
    ...

使用 ECC 加密数据

from EncroX.ecc import ecc_encrypt
encrypted_data = ecc_encrypt(data, public_key, private_key)

使用对方的 ECC 公钥和自己的 ECC 私钥对数据进行加密,并返回加密后的数据。

函数签名

def ecc_encrypt(data, public_key, private_key) -> Union[str, bytes]:
    """
    使用ECC公钥和私钥对数据进行加密。

    Args:
        data (str or bytes): 需要加密的数据,数据类型为字符串或字节。
        public_key (str): 对方的PEM格式ECC公钥。
        private_key (str): 自己的PEM格式ECC私钥。

    Returns:
        str or bytes: 加密后的数据,返回的类型与传入的数据类型相同。
    """
    ...

使用 ECC 解密数据

from EncroX.ecc import ecc_decrypt
decrypted_data = ecc_decrypt(encrypted_data, public_key, private_key)

使用对方的 ECC 公钥和自己的 ECC 私钥解密数据,并返回解密后的原始数据。

函数签名

def ecc_decrypt(encrypted_data, public_key, private_key) -> Union[str, bytes]:
    """
    使用ECC公钥和私钥解密数据。

    Args:
        encrypted_data (str or bytes): 需要解密的数据,数据类型为字符串或字节。
        public_key (str): 对方的PEM格式ECC公钥。
        private_key (str): 自己的PE

M格式ECC私钥。

    Returns:
        str or bytes: 解密后的原始数据,返回的类型与传入的数据类型相同。
    """
    ...

使用 AES 加密数据

from EncroX.aes import aes_encrypt
encrypted_data = aes_encrypt(data, key)

使用 AES 密钥对数据进行加密,并返回加密后的数据。

函数签名

def aes_encrypt(data: Union[str, bytes], key: Union[str, bytes]) -> Union[str, bytes]:
    """
    使用 AES 密钥对数据进行加密。

    Args:
        data (str or bytes): 需要加密的数据,数据类型为字符串或字节。
        key (str or bytes): AES 密钥,当 key 的类型为 bytes 时,长度必须为 16、24 或 32 字节。

    Returns:
        str or bytes: 加密后的数据,返回的类型与传入的数据类型相同。
    """
    ...

使用 AES 解密数据

from EncroX.aes import aes_decrypt
decrypted_data = aes_decrypt(encrypted_data, key)

使用 AES 密钥解密数据,并返回解密后的原始数据。

函数签名

def aes_decrypt(encrypted_data: Union[str, bytes], key: Union[str, bytes]) -> Union[str, bytes]:
    """
    使用 AES 密钥解密数据。

    Args:
        encrypted_data (str or bytes): 需要解密的数据,数据类型为字符串或字节。
        key (str or bytes): AES 密钥,当 key 的类型为 bytes 时,长度必须为 16、24 或 32 字节。

    Returns:
        str or bytes: 解密后的原始数据,返回的类型与传入的数据类型相同。
    """
    ...

安装

您可以使用以下命令安装 EncroX:

pip install EncroX

更多信息

请参阅 EncroX GitHub 仓库 获取更多信息和示例代码。

如果您有任何问题或需要进一步的帮助,请随时联系我们的支持团队。


Metadata

Release files for EncroX 1.1.0

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

Source distribution (sdist)

Source distribution for EncroX 1.1.0
File Size Uploaded
EncroX-1.1.0.tar.gz 20.2 kB Details

Built distribution (wheel)

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

Total release size: 45.9 kB

Release files / EncroX-1.1.0.tar.gz

Download URL EncroX-1.1.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
10761db5360b53dcba8ef3de9628155766bf6ac3c34fc5743d12263484ef7738
BLAKE2b-256 checksum
How to use checksums
c45a210fd0ddeaf8ed1a29dcc691c1944061c1fa3f7f21c1b02fb8b28a885b97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release files / EncroX-1.1.0-py3-none-any.whl

Download URL EncroX-1.1.0-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ccf4c92d5b95bd77c35421edf6698ae8d28244d221d8dbb7b67b02bcb01ab32
BLAKE2b-256 checksum
How to use checksums
5c9555d9773129481dcc54771eccefa2af18c688a76ac7703baf5657c0aea391
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

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