message_cipher.rsa_system module

RSA Crypto System module.

Provides a convenient class that simultaneously acts as both an RsaEncrypter and an RsaDecrypter.

class message_cipher.rsa_system.RSA(prime1: int = 0, prime2: int = 0, exponent: int = 0)

Bases: Cipher, RsaEncrypter, RsaDecrypter

RSA crypto-system constructor. Performs calculations to encrypt strings into an array of integers, and then decrypt those arrays back into strings.

This implements a simplified version of the RSA encryption algorithm.

Parameters:
  • prime1 (int)

  • prime2 (int)

  • exponent (int)

message_cipher.rsa_system.invertible_elements(number: int) list[int]

Calculates all numbers invertible modulo number.

Parameters:

number (int) – The modulo to find invertible numbers in.

Returns:

A list of all invertible elements.

Return type:

list[int]

message_cipher.rsa_system.is_prime(number: int) bool

Checks all possible factors of number up to sqrt(number) to determine its primality.

Parameters:

number (int) – A number to check the primality of.

Returns:

True if number is prime, otherwise False.

Return type:

bool