file_encryptor package

Submodules

file_encryptor.convergence module

file_encryptor.convergence.decrypt_file_inline(filename, key)[source]

Decrypt file inline with given key.

The given key must be the same that was returned by encrypt_file_inline.

Parameters:
  • filename (str) – The name of the file to decrypt.
  • key (str) – The key used to decrypt the file.
file_encryptor.convergence.decrypt_generator(filename, key)[source]

Stream decrypted file with given key.

The given key must be the same that was returned by encrypt_file_inline.

Parameters:
  • filename (str) – The name of the file to decrypt.
  • key (str) – The key used to decrypt the file.
Returns:

A generator that streams decrypted file chunks.

Return type:

generator

file_encryptor.convergence.encrypt_file_inline(filename, passphrase)[source]

Encrypt file inline, with an optional passphrase.

If you set the passphrase to None, a default is used. This will make you vulnerable to confirmation attacks and learn-partial-information attacks.

Parameters:
  • filename (str) – The name of the file to encrypt.
  • passphrase (str or None) – The passphrase used to decrypt the file.
Returns:

The key required to decrypt the file.

Return type:

str

file_encryptor.convergence.inline_transform(filename, key)[source]

Encrypt file inline.

Encrypts a given file with the given key, and replaces it directly without any extra space requirement.

Parameters:
  • filename (str) – The name of the file to decrypt.
  • key (str) – The key used to encrypt the file.
file_encryptor.convergence.iter_transform(filename, key)[source]

Generate encrypted file with given key.

This generator function reads the file in chunks and encrypts them using AES-CTR, with the specified key.

Parameters:
  • filename (str) – The name of the file to encrypt.
  • key (str) – The key used to encrypt the file.
Returns:

A generator that produces encrypted file chunks.

Return type:

generator

file_encryptor.key_generators module

file_encryptor.key_generators.key_from_file(filename, passphrase)[source]

Calculate convergent encryption key.

This takes a filename and an optional passphrase. If no passphrase is given, a default is used. Using the default passphrase means you will be vulnerable to confirmation attacks and learn-partial-information attacks.

Parameters:
  • filename (str) – The filename you want to create a key for.
  • passphrase (str or None) – The passphrase you want to use to encrypt the file.
Returns:

A convergent encryption key.

Return type:

str

file_encryptor.key_generators.keyed_hash(digest, passphrase)[source]

Calculate a HMAC/keyed hash.

Parameters:
  • digest (str) – Digest used to create hash.
  • passphrase (str) – Passphrase used to generate the hash.
Returns:

HMAC/keyed hash.

Return type:

str

file_encryptor.key_generators.sha256_file(path)[source]

Calculate sha256 hex digest of a file.

Parameters:path (str) – The path of the file you are calculating the digest of.
Returns:The sha256 hex digest of the specified file.
Return type:builtin_function_or_method

file_encryptor.settings module

Module contents