Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Tool for convergently encrypting files used by MetaDisk.

Project Description

This is a library used by MetaDisk to convergently encrypt and decrypt files. It contains helper methods to encrypt and decrypt files inline (without using extra space) and to stream decryption.


You can easily install file-encryptor using pip:

pip install file_encryptor


Here’s an example to encrypt a file inline using convergent encryption:

import file_encryptor.convergence

key = convergence.encrypt_inline_file("/path/to/file", None)

You can also specify a passphrase:

import file_encryptor.convergence

key = convergence.encrypt_inline_file("/path/to/file", "rainbow dinosaur secret")

To decrypt a file inline, you need the key that was returned by the encrypt method:

import file_encryptor.convergence

key = convergence.encrypt_inline_file("/path/to/file", "rainbow dinosaur secret")

convergence.decrypt_inline_file("/path/to/file", key)

The reason why you cannot use the passphrase directly is because the key is derived from both the passphrase and the SHA-256 of the original file.

For streaming applications, you can decrypt a file with a generator:

for chunk in convergence.decrypt_generator("/path/to/file", key):


The key generation mechanism is the following:

key = HMAC-SHA256(passphrase, hex(SHA256(file-contents)))

If no passphrase is given, a default is used.

The file itself is encrypted using AES128-CTR, from pycrypto. We’re not specifying any IV, thinking that for convergent encryption that is the right thing to do.


To run tests, execute the following command in the project root:

python test -a "--doctest-modules --pep8 -v tests/"

To run tests with detailed coverage output, execute:

coverage run test -a "--doctest-modules --pep8 -v tests/"
coverage report -m --include="file_encryptor/*"
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
file_encryptor-0.2.9.tar.gz (4.8 kB) Copy SHA256 Checksum SHA256 Source Feb 3, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting