Skip to content

Commit 74d71d0

Browse files
authored
Update fractionated_morse_cipher.py
1 parent df7b182 commit 74d71d0

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

Diff for: ciphers/fractionated_morse_cipher.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
"""
22
Python program for the Fractionated Morse Cipher.
33
4-
The Fractionated Morse cipher first converts the plaintext to morse code,
5-
then enciphers fixed-size blocks of morse code back to letters.
4+
The Fractionated Morse cipher first converts the plaintext to Morse code,
5+
then enciphers fixed-size blocks of Morse code back to letters.
66
This procedure means plaintext letters are mixed into the ciphertext letters,
77
making it more secure than substitution ciphers.
88
99
http://practicalcryptography.com/ciphers/fractionated-morse-cipher/
10-
1110
"""
12-
13-
1411
import string
1512

16-
# Define Morse code dictionary
1713
MORSE_CODE_DICT = {
1814
"A": ".-",
1915
"B": "-...",
@@ -86,7 +82,7 @@ def encode_to_morse(plaintext: str) -> str:
8682
plaintext: The plaintext message to encode.
8783
8884
Returns:
89-
str: The Morse code representation of the plaintext message.
85+
The Morse code representation of the plaintext message.
9086
9187
Example:
9288
>>> encode_to_morse("defend the east")
@@ -99,11 +95,11 @@ def encrypt_fractionated_morse(plaintext: str, key: str) -> str:
9995
"""Encrypt a plaintext message using Fractionated Morse Cipher.
10096
10197
Args:
102-
plaintext (str): The plaintext message to encrypt.
103-
key (str): The encryption key.
98+
plaintext: The plaintext message to encrypt.
99+
key: The encryption key.
104100
105101
Returns:
106-
str: The encrypted ciphertext.
102+
The encrypted ciphertext.
107103
108104
Example:
109105
>>> encrypt_fractionated_morse("defend the east","Roundtable")
@@ -133,11 +129,11 @@ def decrypt_fractionated_morse(ciphertext: str, key: str) -> str:
133129
"""Decrypt a ciphertext message encrypted with Fractionated Morse Cipher.
134130
135131
Args:
136-
ciphertext (str): The ciphertext message to decrypt.
137-
key (str): The decryption key.
132+
ciphertext: The ciphertext message to decrypt.
133+
key: The decryption key.
138134
139135
Returns:
140-
str: The decrypted plaintext message.
136+
The decrypted plaintext message.
141137
142138
Example:
143139
>>> decrypt_fractionated_morse("ESOAVVLJRSSTRX","Roundtable")

0 commit comments

Comments
 (0)