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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file FileEncTool-1.0.1.tar.gz.

File metadata

  • Download URL: FileEncTool-1.0.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for FileEncTool-1.0.1.tar.gz
Algorithm Hash digest
SHA256 33cc47aa48913ef3283fe187ff3594eb38b46dcf07c529fd09b08967019dcf5d
MD5 486a6f8a4a59ff8e8c7bd431e53fdd09
BLAKE2b-256 5d02564d466815a63976506b96f2f5eaad2ff4aef6f5a17caea813a2935164ff

See more details on using hashes here.

File details

Details for the file FileEncTool-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: FileEncTool-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for FileEncTool-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fc2f518438aef8138e75a569d1113f111520275bdf6e6e7e609a1595304e76d
MD5 07e9ee5ed21bc62af233067d77d96b46
BLAKE2b-256 6318dcaf5e866789384ca146b0881ba16e9ea0baa18fca1c4b0add0d411ad8ec

See more details on using hashes here.

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