Skip to main content

File Encryption Tool——A powerful asymmetric file encryption Python library.

Project description

中文文档请访问README_zh.md

encfile Official Documentation

Introduction

Welcome to the encfile library documentation! encfile is a powerful Python library that provides file encryption and decryption functionality. It uses the RSA encryption algorithm and the AES encryption algorithm, supporting both hybrid RSA-AES encryption and pure RSA encryption schemes.

Installation

You can install the encfile library using the pip command:

pip install FileEncTool

Usage Examples

Generating RSA Key Pair

To generate an RSA key pair and save the private key and public key to files, you can use the generate_rsa_keypair function:

from encfile import generate_rsa_keypair

# Generate an RSA key pair and save to files
generate_rsa_keypair(priv_file='private_key.pem', pub_file='public_key.pem')

You can specify the paths for the private key file and public key file. By default, feedback messages are displayed during the key generation process. You can disable the feedback messages by setting the show_feedback parameter to False, as shown below:

from encfile import generate_rsa_keypair

# Generate an RSA key pair and save to files
generate_rsa_keypair(priv_file='private_key.pem', pub_file='public_key.pem', show_feedback=False)

Hybrid RSA-AES Encryption

To encrypt a file using the hybrid RSA-AES encryption scheme, you can use the rsa_aes_encrypt_file function:

from encfile import rsa_aes_encrypt_file

# Encrypt a file using hybrid RSA-AES encryption
rsa_aes_encrypt_file(file_path='plaintext.txt', key_path='public_key.pem', backpath='encrypted_file.enc')

You need to provide the path of the file to be encrypted, the path of the RSA public key file, and the path to save the encrypted file. By default, feedback messages are displayed during the encryption process. You can disable the feedback messages by setting the show_feedback parameter to False, similar to the previous examples.

Hybrid RSA-AES Decryption

To decrypt a file encrypted using the hybrid RSA-AES encryption scheme, you can use the rsa_aes_decrypt_file function:

from encfile import rsa_aes_decrypt_file

# Decrypt a file encrypted using hybrid RSA-AES encryption
rsa_aes_decrypt_file(file_path='encrypted_file.enc', key_path='private_key.pem', backpath='decrypted_file.txt')

You need to provide the path of the encrypted file, the path of the RSA private key file, and the path to save the decrypted file. By default, feedback messages are displayed during the decryption process. You can disable the feedback messages by setting the show_feedback parameter to False, as mentioned above.

Pure RSA Encryption

To encrypt a file using the pure RSA encryption scheme, you can use the rsa_encrypt_file function:

from encfile import rsa_encrypt_file

# Encrypt a file using pure RSA encryption
rsa_encrypt_file(file_path='plaintext.txt', key_path='public_key.pem', backpath='encrypted_file.enc', use_multithreading=False, show_progress=False, show_feedback=False)

You need to provide the path of the file to be encrypted, the path of the RSA public key file, and the path to save the encrypted file. By default, the encryption process uses multithreading and displays a progress bar. You can disable multithreading by setting the use_multithreading parameter to False and disable the progress bar by setting the show_progress parameter to False. By default, feedback messages are displayed during the encryption process. You can disable the feedback messages by setting the show_feedback parameter to False, as shown in the code above.

Pure RSA Decryption

To decrypt a file encrypted using the pure RSA encryption scheme, you can use the rsa_decrypt_file function:

from encfile import rsa_decrypt_file

# Decrypt a file encrypted using pure RSA encryption
rsa_decrypt_file(file_path='encrypted_file.enc', key_path='private_key.pem', backpath='decrypted_file.txt')

You need to provide the path of the encrypted file, the path of the RSA private key file, and the path to save the decrypted file. By default, feedback messages are displayed during the decryption process. You can disable the feedback messages by setting the show_feedback parameter to False, as mentioned above.

Conclusion

The encfile library provides convenient asymmetric file encryption and decryption capabilities. You can use either the RSA-AES hybrid encryption or the pure RSA encryption scheme to protect your files. Make sure to securely store your private key file to prevent data leaks. If you have any further questions, please refer to the comments in the init.py file or contact the author.

License

This project is licensed under the AGPL 3.0 license. See the LICENSE file for details.

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

FileEncTool-1.0.1.tar.gz (17.9 kB view hashes)

Uploaded Source

Built Distribution

FileEncTool-1.0.1-py3-none-any.whl (16.9 kB view hashes)

Uploaded Python 3

Supported by

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