Skip to main content

Encrypts and decrypts image files using AES encryption in GCM mode.

Project description

AEIF (AES Encrypted Image File) Library

The AEIF (AES Encrypted Image File) library is a Python library that provides functionality for encrypting and decrypting image files using the AES encryption algorithm.

Installation

You can install the AEIF library using pip:

pip install aeif-lib

Usage

Generating a key

To generate a key, you can use the genkey function:

from aeif_lib import genkey

# Generate a random key with the specified size
# (only 16, 24, and 32 bytes is supported) and save it to a file
key_path, key = genkey("path/to/save/key")

Encrypting an image

To encrypt an image, you can use the encrypt function:

from aeif_lib import AEIFManager, genkey, verify_hash

key_path, _ = genkey("path/to/save/key", 32)

# Create an AEIFManager object
# (key_path is optional but will be required for encryption/decryption if not set)
aeif = AEIFManager(key_path)

# Encrypt the image (key or key_path is optional if the key is already set)
aeif.encrypt("./img.png", "./img_e.aeif")

Decrypting an image

To decrypt an image, you can use the decrypt function:

from aeif_lib import AEIFManager

key_path = "path/to/the/key"

# Create an AEIFManager object
# (key_path is optional but will be required for encryption/decryption if not set)
aeif = AEIFManager(key_path)

# Decrypt the image (key or key_path is optional if the key is already set)
aeif.decrypt("./img_e.aeif", "./img_d.png")

# Verify the hash of the original image and the decrypted image
verify = verify_hash(("./img.png", "./img_d.png"))
print("Hashes match!" if verify else "Hashes do not match!")

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

aeif-lib-0.0.3.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

aeif_lib-0.0.3-py3-none-any.whl (4.2 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