Skip to content

Commit 0de53b9

Browse files
update running key cipher add doctests and hints
1 parent 960ff5d commit 0de53b9

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Diff for: ciphers/running_key_cipher.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
def running_key_encrypt(key, plaintext):
1+
def running_key_encrypt(key: str, plaintext: str) -> str:
2+
"""
3+
Encrypts the plaintext using the Running Key Cipher.
4+
5+
:param key: The running key (long piece of text).
6+
:param plaintext: The plaintext to be encrypted.
7+
:return: The ciphertext.
8+
"""
29
plaintext = plaintext.replace(" ", "").upper()
310
key = key.replace(" ", "").upper()
411
key_length = len(key)
@@ -13,7 +20,14 @@ def running_key_encrypt(key, plaintext):
1320
return "".join(ciphertext)
1421

1522

16-
def running_key_decrypt(key, ciphertext):
23+
def running_key_decrypt(key: str, ciphertext: str) -> str:
24+
"""
25+
Decrypts the ciphertext using the Running Key Cipher.
26+
27+
:param key: The running key (long piece of text).
28+
:param ciphertext: The ciphertext to be decrypted.
29+
:return: The plaintext.
30+
"""
1731
ciphertext = ciphertext.replace(" ", "").upper()
1832
key = key.replace(" ", "").upper()
1933
key_length = len(key)

0 commit comments

Comments
 (0)