escale.encryption package

class escale.encryption.Cipher(passphrase)

Bases: object

Partially abstract class that encrypts and decrypts file.

A concrete Cipher class should implement _encrypt() and _decrypt().

passphrase

arbitrarily long passphrase.

Type:str-like
_temporary_files

list of paths to existing temporary files.

Type:list
finalize(cipher)

Example:

temp_file = cipher.encrypt(plain_file)
# manipulate encrypted file `temp_file`
cipher.finalize(temp_file)
# `temp_file` is no longer available
prepare(plain)

Example:

# plain_file may refer to a non-existing file
temp_file = cipher.prepare(plain_file)
# get encrypted file as `temp_file`,
# and then decrypt it into `target_file`:
cipher.decrypt(temp_file, plain_file)
# `temp_file` is no longer available
class escale.encryption.Plain(*ignored)

Bases: escale.encryption.encryption.Cipher

Concrete implementation of Cipher that actually does not cipher.

finalize(cipher)

Example:

temp_file = cipher.encrypt(plain_file)
# manipulate encrypted file `temp_file`
cipher.finalize(temp_file)
# `temp_file` is no longer available
prepare(plain)

Example:

# plain_file may refer to a non-existing file
temp_file = cipher.prepare(plain_file)
# get encrypted file as `temp_file`,
# and then decrypt it into `target_file`:
cipher.decrypt(temp_file, plain_file)
# `temp_file` is no longer available
class escale.encryption.Blowfish(passphrase, mode='OFB')

Bases: escale.encryption.encryption.Cipher

Blowfish encryption based on the cryptography library.

class escale.encryption.Fernet(passphrase)

Bases: escale.encryption.encryption.Cipher

See also cryptography.io/en/latest/fernet.

escale.encryption.encryption module

class escale.encryption.encryption.Cipher(passphrase)

Bases: object

Partially abstract class that encrypts and decrypts file.

A concrete Cipher class should implement _encrypt() and _decrypt().

passphrase

arbitrarily long passphrase.

Type:str-like
_temporary_files

list of paths to existing temporary files.

Type:list
decrypt(cipher, plain=None, consume=True, makedirs=True)
encrypt(plain, cipher=None)
finalize(cipher)

Example:

temp_file = cipher.encrypt(plain_file)
# manipulate encrypted file `temp_file`
cipher.finalize(temp_file)
# `temp_file` is no longer available
prepare(plain)

Example:

# plain_file may refer to a non-existing file
temp_file = cipher.prepare(plain_file)
# get encrypted file as `temp_file`,
# and then decrypt it into `target_file`:
cipher.decrypt(temp_file, plain_file)
# `temp_file` is no longer available
class escale.encryption.encryption.Plain(*ignored)

Bases: escale.encryption.encryption.Cipher

Concrete implementation of Cipher that actually does not cipher.

decrypt(cipher, plain=None, consume=False)
encrypt(plain, cipher=None)
finalize(cipher)

Example:

temp_file = cipher.encrypt(plain_file)
# manipulate encrypted file `temp_file`
cipher.finalize(temp_file)
# `temp_file` is no longer available
prepare(plain)

Example:

# plain_file may refer to a non-existing file
temp_file = cipher.prepare(plain_file)
# get encrypted file as `temp_file`,
# and then decrypt it into `target_file`:
cipher.decrypt(temp_file, plain_file)
# `temp_file` is no longer available

escale.encryption.fernet module

The fernet module provides the recommended implementation for the Cipher class. It is based on the cryptography library.

class escale.encryption.fernet.Fernet(passphrase)

Bases: escale.encryption.encryption.Cipher

See also cryptography.io/en/latest/fernet.

escale.encryption.blowfish module

The blowfish module is actually a package that accomodates several implementations refered to as backends.

The cryptography backend prevails if the cryptography library is available (see here). Otherwise, Blowfish is implemented with blowfish as a backend (blowfish library).

class escale.encryption.blowfish.Blowfish(passphrase, mode='OFB')

Bases: escale.encryption.encryption.Cipher

Blowfish encryption based on the cryptography library.

escale.encryption.blowfish.blowfish module

escale.encryption.blowfish.cryptography module

class escale.encryption.blowfish.cryptography.Blowfish(passphrase, mode='OFB')

Bases: escale.encryption.encryption.Cipher

Blowfish encryption based on the cryptography library.