Ciphers¶
The rite.crypto.cipher submodule implements classical ciphers useful for demonstrations and simple transformations (not for high-security use).
Rite - Cryptography - Cipher Module¶
This module serves as the central import hub for all classical ciphers implemented in the Rite cryptography toolkit. It exposes both encode and decode functions for a variety of historical and educational ciphers.
Available ciphers
- Atbash
- Autokey
- Baconian
- Caesar
- Four-Square
- Playfair
- Rail Fence
- Rot13
- Scytale
- Transposition
- Vigenère
- XOR
Functions¶
decode_atbash_cipher(text: str) -> str
¶
Decode text using the Atbash cipher.
This is functionally identical to encoding, since Atbash is symmetric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The Atbash-encoded string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded string (same as encoding). |
decode_autokey_cipher(encoded_text: str, key: str) -> str
¶
Decode text using the Autokey cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
key
|
str
|
The original cipher key. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext. |
decode_baconian_cipher(encoded_text: str) -> str
¶
Decode Baconian-encoded text (a/b) back into plaintext.
Ignores incomplete final segments and assumes input is clean (only 'a' and 'b').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
A string of 'a' and 'b' characters, in chunks of 5. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext. |
decode_caesar_cipher(encoded_text: str, shift: int) -> str
¶
Decode Caesar cipher text by reversing the shift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
shift
|
int
|
The original shift used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext string. |
decode_four_square_cipher(encoded_text: str, key1: str, key2: str) -> str
¶
Decode ciphertext encoded with the Four-Square cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The encrypted message to decode. |
required |
key1
|
str
|
Key used for the top-right square. |
required |
key2
|
str
|
Key used for the bottom-left square. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded plaintext. |
decode_playfair_cipher(encoded_text: str, key: str) -> str
¶
Decode Playfair-encoded ciphertext.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The encoded string. |
required |
key
|
str
|
Cipher key used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext (not automatically de-padded). |
decode_rail_fence_cipher(encoded_text: str, num_rails: int) -> str
¶
Decode a Rail Fence-encoded string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The encoded string to decode. |
required |
num_rails
|
int
|
Number of rails used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The original decoded plaintext string. |
decode_rot13_cipher(text: str) -> str
¶
Decode text using the Rot13 cipher.
This is functionally identical to encoding, as Rot13 is symmetric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The Rot13-encoded text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded text. |
decode_scytale_cipher(encoded_text: str, diameter: int) -> str
¶
Decode a Scytale-encoded string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
diameter
|
int
|
Number of columns used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext string. |
decode_transposition_cipher(encoded_text: str, key: int, strip_padding: bool = True) -> str
¶
Decode text from a simple columnar transposition cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The transposed text to decode. |
required |
key
|
int
|
The number of columns used in encoding. |
required |
strip_padding
|
bool
|
Whether to strip trailing padding spaces (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The decoded (original) text. |
decode_vigenere_cipher(encoded_text: str, key: str) -> str
¶
Decode text from the Vigenère cipher.
Non-alphabet characters are preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
key
|
str
|
The keyword originally used to encode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded plaintext. |
decode_xor_cipher(text: str, key: str) -> str
¶
Decode XOR-encoded text using the same key.
This function is equivalent to encode_xor_cipher().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The XOR-encoded string. |
required |
key
|
str
|
The encryption key used for encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded plaintext string. |
encode_atbash_cipher(text: str) -> str
¶
Encode (or decode) text using the Atbash cipher.
Since Atbash is symmetric, the same function can be used for encoding and decoding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input string to encode or decode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The Atbash-encoded/decoded string. |
encode_autokey_cipher(text: str, key: str) -> str
¶
Encode text using the Autokey cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key
|
str
|
The cipher key (only letters are used). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext. |
encode_baconian_cipher(text: str) -> str
¶
Encode plaintext using the Baconian cipher.
Non-alphabetic characters are ignored. All letters are converted to lowercase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input text to encode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A string of 'a' and 'b' representing the encoded text. |
encode_caesar_cipher(text: str, shift: int) -> str
¶
Encode text using the Caesar cipher.
Only alphabetic characters are shifted. Case is preserved. Other characters remain unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext string to encode. |
required |
shift
|
int
|
The number of positions to shift (can be positive or negative). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext string. |
encode_four_square_cipher(text: str, key1: str, key2: str) -> str
¶
Encode text using the Four-Square cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key1
|
str
|
Key for the top-right square. |
required |
key2
|
str
|
Key for the bottom-left square. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The encoded ciphertext. |
encode_playfair_cipher(text: str, key: str) -> str
¶
Encode plaintext using the Playfair cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input plaintext. |
required |
key
|
str
|
Cipher key for generating the Playfair square. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext. |
encode_rail_fence_cipher(text: str, num_rails: int) -> str
¶
Encode text using the Rail Fence cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
num_rails
|
int
|
Number of rails (rows) to use in the zigzag pattern. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext string. |
encode_rot13_cipher(text: str) -> str
¶
Encode or decode text using the Rot13 cipher.
Since Rot13 is symmetric, this function is used for both encoding and decoding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input text to encode or decode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The transformed text. |
encode_scytale_cipher(text: str, diameter: int) -> str
¶
Encode a string using the Scytale cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input plaintext. |
required |
diameter
|
int
|
Number of columns (characters per wrap-around). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext. |
encode_transposition_cipher(text: str, key: int) -> str
¶
Encode text using a simple columnar transposition cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key
|
int
|
The number of columns (i.e., transposition key). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The encoded (scrambled) text. |
encode_vigenere_cipher(text: str, key: str) -> str
¶
Encode text using the Vigenère cipher.
Non-alphabet characters are preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key
|
str
|
The keyword used to perform letter shifts. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The encoded ciphertext. |
encode_xor_cipher(text: str, key: str) -> str
¶
Encode or decode text using the XOR cipher.
Since XOR is symmetric, this function performs both encryption and decryption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext or ciphertext string. |
required |
key
|
str
|
The encryption key. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str
|
A string with the result of XOR encryption/decryption. |
|
Note |
str
|
Non-printable characters may be present in the result. |
four_square_cipher_pair(pair: str, square_tl: list[list[str]], square_tr: list[list[str]], square_bl: list[list[str]], square_br: list[list[str]], mode: str = 'encode') -> str
¶
Encode or decode a letter pair using the Four-Square cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pair
|
str
|
A two-character string. |
required |
square_tl
|
list[list[str]]
|
Top-left square (standard). |
required |
square_tr
|
list[list[str]]
|
Top-right square (key 1). |
required |
square_bl
|
list[list[str]]
|
Bottom-left square (key 2). |
required |
square_br
|
list[list[str]]
|
Bottom-right square (standard). |
required |
mode
|
str
|
'encode' or 'decode'. |
'encode'
|
Returns:
| Type | Description |
|---|---|
str
|
Encoded or decoded letter pair. |
Modules¶
cipher_atbash
¶
Rite - Cryptography - Cipher - Atbash Cipher Module¶
Provides functionality to encode and decode text using the Atbash cipher.
The Atbash cipher is a classical substitution cipher that reverses the alphabet (A ↔ Z, B ↔ Y, ..., a ↔ z).
References¶
Functions¶
decode_atbash_cipher(text: str) -> str
¶
Decode text using the Atbash cipher.
This is functionally identical to encoding, since Atbash is symmetric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The Atbash-encoded string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded string (same as encoding). |
encode_atbash_cipher(text: str) -> str
¶
Encode (or decode) text using the Atbash cipher.
Since Atbash is symmetric, the same function can be used for encoding and decoding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input string to encode or decode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The Atbash-encoded/decoded string. |
cipher_autokey
¶
Rite - Cryptography - Cipher - Autokey Cipher Module¶
Provides functionality to encode and decode text using the Autokey cipher.
The Autokey cipher is a polyalphabetic substitution cipher that extends the key with the plaintext itself during encoding, and with the decoded text during decoding.
References¶
Functions¶
decode_autokey_cipher(encoded_text: str, key: str) -> str
¶
Decode text using the Autokey cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
key
|
str
|
The original cipher key. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext. |
encode_autokey_cipher(text: str, key: str) -> str
¶
Encode text using the Autokey cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key
|
str
|
The cipher key (only letters are used). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext. |
cipher_baconian
¶
Rite - Cryptography - Cipher - Baconian Cipher Module¶
Provides functionality to encode and decode text using the Baconian cipher.
The Baconian cipher encodes each letter of the alphabet using a unique 5-letter combination of 'a' and 'b'. It is a classical steganographic cipher.
References¶
Functions¶
decode_baconian_cipher(encoded_text: str) -> str
¶
Decode Baconian-encoded text (a/b) back into plaintext.
Ignores incomplete final segments and assumes input is clean (only 'a' and 'b').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
A string of 'a' and 'b' characters, in chunks of 5. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext. |
encode_baconian_cipher(text: str) -> str
¶
Encode plaintext using the Baconian cipher.
Non-alphabetic characters are ignored. All letters are converted to lowercase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input text to encode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A string of 'a' and 'b' representing the encoded text. |
cipher_caesar
¶
Rite - Cryptography - Cipher - Caesar Cipher Module¶
Provides functionality to encode and decode text using the Caesar cipher.
The Caesar cipher is a substitution cipher that shifts characters by a fixed offset.
References¶
Functions¶
decode_caesar_cipher(encoded_text: str, shift: int) -> str
¶
Decode Caesar cipher text by reversing the shift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
shift
|
int
|
The original shift used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext string. |
encode_caesar_cipher(text: str, shift: int) -> str
¶
Encode text using the Caesar cipher.
Only alphabetic characters are shifted. Case is preserved. Other characters remain unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext string to encode. |
required |
shift
|
int
|
The number of positions to shift (can be positive or negative). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext string. |
cipher_four_square
¶
Rite - Cryptography - Cipher - Four-Square Cipher Module¶
Provides functionality to encode and decode text using the Four-Square cipher.
This classical cipher uses four 5x5 matrices to encode letter pairs.
References¶
Functions¶
decode_four_square_cipher(encoded_text: str, key1: str, key2: str) -> str
¶
Decode ciphertext encoded with the Four-Square cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The encrypted message to decode. |
required |
key1
|
str
|
Key used for the top-right square. |
required |
key2
|
str
|
Key used for the bottom-left square. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded plaintext. |
encode_four_square_cipher(text: str, key1: str, key2: str) -> str
¶
Encode text using the Four-Square cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key1
|
str
|
Key for the top-right square. |
required |
key2
|
str
|
Key for the bottom-left square. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The encoded ciphertext. |
find_position(letter: str, square: list[list[str]]) -> tuple[int, int]
¶
Find the (row, col) position of a letter in a 5x5 matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
letter
|
str
|
The letter to locate. |
required |
square
|
list[list[str]]
|
A 5x5 matrix. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
(row_index, col_index) of the letter. |
four_square_cipher_pair(pair: str, square_tl: list[list[str]], square_tr: list[list[str]], square_bl: list[list[str]], square_br: list[list[str]], mode: str = 'encode') -> str
¶
Encode or decode a letter pair using the Four-Square cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pair
|
str
|
A two-character string. |
required |
square_tl
|
list[list[str]]
|
Top-left square (standard). |
required |
square_tr
|
list[list[str]]
|
Top-right square (key 1). |
required |
square_bl
|
list[list[str]]
|
Bottom-left square (key 2). |
required |
square_br
|
list[list[str]]
|
Bottom-right square (standard). |
required |
mode
|
str
|
'encode' or 'decode'. |
'encode'
|
Returns:
| Type | Description |
|---|---|
str
|
Encoded or decoded letter pair. |
generate_square(key: str) -> list[list[str]]
¶
Generate a 5x5 matrix for the Four-Square cipher using a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Keyword to populate the matrix. |
required |
Returns:
| Type | Description |
|---|---|
list[list[str]]
|
A 5x5 list of characters (J is merged with I). |
cipher_playfair
¶
Playfair Cipher Module¶
Provides functionality to encode and decode text using the Playfair cipher.
This classical digraph cipher uses a 5x5 matrix to substitute pairs of letters.
References¶
Functions¶
create_playfair_square(key: str) -> list[list[str]]
¶
Create a 5x5 Playfair square using the given key.
J is omitted (merged with I), and duplicates are removed in order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The keyword to use for square generation. |
required |
Returns:
| Type | Description |
|---|---|
list[list[str]]
|
A 5x5 list of characters. |
decode_playfair_cipher(encoded_text: str, key: str) -> str
¶
Decode Playfair-encoded ciphertext.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The encoded string. |
required |
key
|
str
|
Cipher key used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext (not automatically de-padded). |
encode_playfair_cipher(text: str, key: str) -> str
¶
Encode plaintext using the Playfair cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input plaintext. |
required |
key
|
str
|
Cipher key for generating the Playfair square. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext. |
find_position(letter: str, square: list[list[str]]) -> tuple[int, int]
¶
Find (row, col) of a letter in the Playfair square.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
letter
|
str
|
The letter to locate. |
required |
square
|
list[list[str]]
|
The 5x5 matrix. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (row_index, col_index) |
playfair_cipher_pair(pair: str, square: list[list[str]], mode: str = 'encode') -> str
¶
Encode or decode a digraph using the Playfair cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pair
|
str
|
Two-letter string. |
required |
square
|
list[list[str]]
|
The Playfair square. |
required |
mode
|
str
|
'encode' or 'decode'. |
'encode'
|
Returns:
| Type | Description |
|---|---|
str
|
Encoded or decoded two-letter string. |
prepare_text(text: str) -> str
¶
Prepare text for Playfair encoding.
Replaces J with I, removes non-alphabetic characters, inserts 'X' between duplicate letters, and pads the end if necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Raw input text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cleaned and paired text ready for encoding. |
cipher_rail_fence
¶
Rite - Cryptography - Cipher - Rail Fence Cipher Module¶
Provides functionality to encode and decode text using the Rail Fence cipher.
The Rail Fence cipher is a transposition cipher that rearranges characters in a zigzag pattern across a fixed number of rails (rows).
References¶
Functions¶
decode_rail_fence_cipher(encoded_text: str, num_rails: int) -> str
¶
Decode a Rail Fence-encoded string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The encoded string to decode. |
required |
num_rails
|
int
|
Number of rails used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The original decoded plaintext string. |
encode_rail_fence_cipher(text: str, num_rails: int) -> str
¶
Encode text using the Rail Fence cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
num_rails
|
int
|
Number of rails (rows) to use in the zigzag pattern. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext string. |
cipher_rot13
¶
Rite - Cryptography - Cipher - Rot13 Cipher Module¶
Provides functionality to encode and decode text using the Rot13 cipher.
The Rot13 cipher shifts each letter 13 places in the alphabet and is symmetric (i.e., encoding and decoding are the same operation).
References¶
Functions¶
decode_rot13_cipher(text: str) -> str
¶
Decode text using the Rot13 cipher.
This is functionally identical to encoding, as Rot13 is symmetric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The Rot13-encoded text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded text. |
encode_rot13_cipher(text: str) -> str
¶
Encode or decode text using the Rot13 cipher.
Since Rot13 is symmetric, this function is used for both encoding and decoding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input text to encode or decode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The transformed text. |
cipher_scytale
¶
Rite - Cryptography - Cipher - Scytale Cipher Module¶
The Scytale cipher wraps text around a rod (cylinder) of fixed diameter, writing along its length and reading across its circumference.
References¶
Functions¶
decode_scytale_cipher(encoded_text: str, diameter: int) -> str
¶
Decode a Scytale-encoded string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
diameter
|
int
|
Number of columns used during encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Decoded plaintext string. |
encode_scytale_cipher(text: str, diameter: int) -> str
¶
Encode a string using the Scytale cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input plaintext. |
required |
diameter
|
int
|
Number of columns (characters per wrap-around). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Encoded ciphertext. |
cipher_transposition
¶
Rite - Cryptography - Cipher - Transposition Cipher Module¶
Provides functionality to encode and decode text using a columnar transposition cipher.
The transposition cipher rearranges the characters of the plaintext based on a fixed number of columns (key).
References¶
Functions¶
decode_transposition_cipher(encoded_text: str, key: int, strip_padding: bool = True) -> str
¶
Decode text from a simple columnar transposition cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The transposed text to decode. |
required |
key
|
int
|
The number of columns used in encoding. |
required |
strip_padding
|
bool
|
Whether to strip trailing padding spaces (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The decoded (original) text. |
encode_transposition_cipher(text: str, key: int) -> str
¶
Encode text using a simple columnar transposition cipher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key
|
int
|
The number of columns (i.e., transposition key). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The encoded (scrambled) text. |
cipher_vigenere
¶
Rite - Cryptography - Cipher - Vigenère Cipher Module¶
Provides functionality to encode and decode text using the Vigenère cipher.
The Vigenère cipher is a method of encrypting alphabetic text by using a simple form of polyalphabetic substitution based on a keyword.
References¶
Functions¶
decode_vigenere_cipher(encoded_text: str, key: str) -> str
¶
Decode text from the Vigenère cipher.
Non-alphabet characters are preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_text
|
str
|
The ciphertext to decode. |
required |
key
|
str
|
The keyword originally used to encode. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded plaintext. |
encode_vigenere_cipher(text: str, key: str) -> str
¶
Encode text using the Vigenère cipher.
Non-alphabet characters are preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext to encode. |
required |
key
|
str
|
The keyword used to perform letter shifts. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The encoded ciphertext. |
cipher_xor
¶
Rite - Cryptography - Cipher - XOR Cipher Module¶
Provides functionality to encode and decode text using the XOR cipher.
The XOR cipher is a symmetric key encryption technique that uses the XOR (bitwise exclusive OR) operation between the plaintext and a repeating key.
References¶
Functions¶
decode_xor_cipher(text: str, key: str) -> str
¶
Decode XOR-encoded text using the same key.
This function is equivalent to encode_xor_cipher().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The XOR-encoded string. |
required |
key
|
str
|
The encryption key used for encoding. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The decoded plaintext string. |
encode_xor_cipher(text: str, key: str) -> str
¶
Encode or decode text using the XOR cipher.
Since XOR is symmetric, this function performs both encryption and decryption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The plaintext or ciphertext string. |
required |
key
|
str
|
The encryption key. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str
|
A string with the result of XOR encryption/decryption. |
|
Note |
str
|
Non-printable characters may be present in the result. |
options: show_root_heading: true show_source: false heading_level: 2