Skip to main content

allows one to easily encrypt and decrypt files symmetrically using openssl and python3

Project description

fileenc-openssl

This code allows one to easily encrypt and decrypt files symmetrically using openssl and python3.

Uses aes-256-cbc for file encryption, with salt, sha256 key stretching and sha256 checksum.

Installation

You can install using

pip install fileenc-openssl

Usage

From command line:

fileenc --key 'password123' --input '*.png' --check --overwrite
filedec --key 'password123' --input '*.png.enc' --check --overwrite --remove

From python:

from fileenc_openssl import stretch_key, encrypt_file, decrypt_file
stretched_key = stretch_key('password123')
enc_pth = encrypt_file(raw_pth, key=stretched_key)
res_pth = decrypt_file(enc_pth, key=stretched_key)

Testing (needs py.test):

py.test

Options

You can find all options using fileenc --help:

-h, --help              show this help message and exit
-k KEY, --key KEY       the key to use for encryption; you will be prompted for one if this is not provided (more secure)
-i INP, --input INP     input file, directory or pattern (as a single string) (.enc will be appended)
-o OUTP, --output OUTP  optionally, output file or directory (.enc will be stripped if available)
-d, --decrypt           decrypt the input file(s) (as opposed to encrypt, which is the default)
-f, --overwrite         overwrite existing files when decrypting (encrypting always overwrites)
-r, --remove            remove the input file after en/decrypting (after --check)
-c, --check             test the encryption by reversing it (abort on failure) (only for ENcryption due to salting)

License

Revised BSD License; at your own risk, you can mostly do whatever you want with this code, just don’t use my name for promotion and do keep the license file.

Future

  • Multiprocessing for multiple files

  • Faster checksum algorithm?

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

fileenc-openssl-1.1.1.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file fileenc-openssl-1.1.1.tar.gz.

File metadata

File hashes

Hashes for fileenc-openssl-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8b199b92ac5ea2b75cb642edc0ad8b4854c057920ab7d797384615c39bb7e715
MD5 d5e30def7f5095d87396f3a0e3b12d57
BLAKE2b-256 f86dbf6626e429f92581ba217ec9bddb4db7372c2f559ad379944c304da9c800

See more details on using hashes here.

Supported by

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