message_cipher.conversions module

Conversions module.

This module defines functions for converting between characters and integers.

message_cipher.conversions.char_to_int(char: str) int

Converts single character to numerical value.

Parameters:

char (str) – A string of length 1 containing a letter.

Returns:

An integer representation of char.

Raises:
  • TypeError – If char is not a single character (string of length 1).

  • ValueError – If char is not an english letter.

Return type:

int

message_cipher.conversions.int_to_char(number: int) str

Converts an integer to a character.

Parameters:

number (int) – An integer to convert.

Returns:

A string of length 1 containing letter representation of number.

Raises:

ValueError – If number is not within the bounds [0, 26).

Return type:

str