Skip to content

Add running key cipher #10834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update running key cipher add doctests and hints
  • Loading branch information
ArshdeepSingh98 committed Oct 23, 2023
commit 0de53b9e6a5d5b943911853b26877b56f0adc6f0
18 changes: 16 additions & 2 deletions ciphers/running_key_cipher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
def running_key_encrypt(key, plaintext):
def running_key_encrypt(key: str, plaintext: str) -> str:
"""
Encrypts the plaintext using the Running Key Cipher.

:param key: The running key (long piece of text).
:param plaintext: The plaintext to be encrypted.
:return: The ciphertext.
"""
plaintext = plaintext.replace(" ", "").upper()
key = key.replace(" ", "").upper()
key_length = len(key)
Expand All @@ -13,7 +20,14 @@ def running_key_encrypt(key, plaintext):
return "".join(ciphertext)


def running_key_decrypt(key, ciphertext):
def running_key_decrypt(key: str, ciphertext: str) -> str:
"""
Decrypts the ciphertext using the Running Key Cipher.

:param key: The running key (long piece of text).
:param ciphertext: The ciphertext to be decrypted.
:return: The plaintext.
"""
ciphertext = ciphertext.replace(" ", "").upper()
key = key.replace(" ", "").upper()
key_length = len(key)
Expand Down