message_cipher.affine_cipher module
Affine Cipher module.
This module defines the AffineCipher class, which is a concrete implementation of the Mod26Cipher class.
The AffineCipher class uses the Affine cipher algorithm for encryption and decryption.
- class message_cipher.affine_cipher.AffineCipher
Bases:
Mod26Cipher
Encrypt and decrypt alphabetic text using the Affine Cipher algorithm.
- INVERTIBLE_ELEMENTS: Final = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]
- __init__(degree_one: int, degree_zero: int) None
Initialize a new Affine cipher with coefficients
degree_one
anddegree_zero
.- Parameters:
degree_one (int) – The polynomial degree one coefficient of the Affine cipher.
degree_zero (int) – The polynomial degree zero coefficient of the Affine cipher.
- Return type:
None
- message_cipher.affine_cipher.inverse_modulo_26(number: int) int
Calculate the multiplicative inverse of
number
modulo 26.- Parameters:
number (int) – A number to calculate the inverse of.
- Returns:
The multiplicative inverse of number.
- Return type:
int