jmath.cryptography package

Submodules

jmath.cryptography.affine module

Affine cipher and Affine cipher relevant tools.

class jmath.cryptography.affine.Affine(a, b, char_set='abcdefghijklmnopqrstuvwxyz')

Bases: object

Creates an affine cipher

(ax + b) % len(set_length)

Parameters
  • a (int) – Value to multiply x by

  • b (int) – Value to add to x

  • char_set (Tuple[str]) – Ordered set (tuple) of valid characters

Raises

OutOfRange – Given if a or b are outside of the range from 0 to the length of the character set minus one.

property a

Value that x is multiplied by in the encryption process.

property b

Value that x is added to in the encryption process.

property char_set

Ordered set of unique characters to used in the cipher.

decrypt(string, split_char='')

Decrypts a string of numbers as per the affine cipher

Parameters
  • string (str) – The string to be decrypted by the affine cipher, expects splits by spaces.

  • split_char (str) – The character between encrypted values.

Return type

str

encrypt(string, split_char='')

Encrypts a string of letters as per the affine cipher.

Parameters
  • string (str) – The string to be encrypted by the affine cipher

  • split_char (str) – The value to insert between encrypted values.

Return type

str

jmath.cryptography.tools module

Tools for analysing cipher text

jmath.cryptography.tools.character_frequencies(cipher_text, split_char='')

Records the most commonly occuring frequencies in the cipher text.

Parameters
  • cipher_text (str) – The text to analyse

  • split_char (str) – The character to split items around, defaults to none.

Return type

Dict[str, int]

Module contents

Cryptography tools.

Default Packages

jmath.cryptography.affine

Provides tools for using affine ciphers