-
-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
create beaufort cipher #3206
create beaufort cipher #3206
Conversation
if you like my code, merge it and add the label as `hacktoberfest-accepted`
Please run your code thru psf/black as discussed in CONTRIBUTING.md. |
Here we need single quotes... https://travis-ci.com/github/TheAlgorithms/Python/builds/190633967#L782-L804 |
ciphers/beaufort_cipher.py
Outdated
>>> generate_key('THE GERMAN ATTACK','SECRET') | ||
SECRETSECRETSECRE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> generate_key('THE GERMAN ATTACK','SECRET') | |
SECRETSECRETSECRE | |
>>> generate_key("THE GERMAN ATTACK", "SECRET") | |
'SECRETSECRETSECRE' |
Travis tests have failedHey @radadiyamohit81, TravisBuddy Request Identifier: f23bf070-1073-11eb-af89-615b230ba186 |
Thank you @cclauss for helping me Thank you so much |
ciphers/beaufort_cipher.py
Outdated
dict1 = { | ||
"A": 0, | ||
"B": 1, | ||
"C": 2, | ||
"D": 3, | ||
"E": 4, | ||
"F": 5, | ||
"G": 6, | ||
"H": 7, | ||
"I": 8, | ||
"J": 9, | ||
"K": 10, | ||
"L": 11, | ||
"M": 12, | ||
"N": 13, | ||
"O": 14, | ||
"P": 15, | ||
"Q": 16, | ||
"R": 17, | ||
"S": 18, | ||
"T": 19, | ||
"U": 20, | ||
"V": 21, | ||
"W": 22, | ||
"X": 23, | ||
"Y": 24, | ||
"Z": 25, | ||
} | ||
|
||
dict2 = { | ||
0: "A", | ||
1: "B", | ||
2: "C", | ||
3: "D", | ||
4: "E", | ||
5: "F", | ||
6: "G", | ||
7: "H", | ||
8: "I", | ||
9: "J", | ||
10: "K", | ||
11: "L", | ||
12: "M", | ||
13: "N", | ||
14: "O", | ||
15: "P", | ||
16: "Q", | ||
17: "R", | ||
18: "S", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dict1 = { | |
"A": 0, | |
"B": 1, | |
"C": 2, | |
"D": 3, | |
"E": 4, | |
"F": 5, | |
"G": 6, | |
"H": 7, | |
"I": 8, | |
"J": 9, | |
"K": 10, | |
"L": 11, | |
"M": 12, | |
"N": 13, | |
"O": 14, | |
"P": 15, | |
"Q": 16, | |
"R": 17, | |
"S": 18, | |
"T": 19, | |
"U": 20, | |
"V": 21, | |
"W": 22, | |
"X": 23, | |
"Y": 24, | |
"Z": 25, | |
} | |
dict2 = { | |
0: "A", | |
1: "B", | |
2: "C", | |
3: "D", | |
4: "E", | |
5: "F", | |
6: "G", | |
7: "H", | |
8: "I", | |
9: "J", | |
10: "K", | |
11: "L", | |
12: "M", | |
13: "N", | |
14: "O", | |
15: "P", | |
16: "Q", | |
17: "R", | |
18: "S", | |
from string import ascii_uppercase | |
dict1 = {char: i for i, char in enumerate(ascii_uppercase)} | |
dict2 = {i: char for i, char in enumerate(ascii_uppercase)} |
Dict comprehensions!
ciphers/beaufort_cipher.py
Outdated
|
||
# This function returns the encrypted text | ||
# generated with the help of the key | ||
def cipherText(message: str, key_new: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def cipherText(message: str, key_new: str) -> str: | |
def cipher_text(message: str, key_new: str) -> str: |
ciphers/beaufort_cipher.py
Outdated
|
||
# This function decrypts the encrypted text | ||
# and returns the original text | ||
def originalText(cipher_text: str, key_new: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def originalText(cipher_text: str, key_new: str) -> str: | |
def original_text(cipher_text: str, key_new: str) -> str: |
ciphers/beaufort_cipher.py
Outdated
cipher_text = cipherText(message, key_new) | ||
original_text = originalText(cipher_text, key_new) | ||
print("Encrypted Text =", cipher_text) | ||
print("Original Text =", original_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cipher_text = cipherText(message, key_new) | |
original_text = originalText(cipher_text, key_new) | |
print("Encrypted Text =", cipher_text) | |
print("Original Text =", original_text) | |
s = cipher_text(message, key_new) | |
print(f"Encrypted Text = {s}") | |
print(f"Original Text = {original_text(s, key_new)}") |
f-strings...
Travis tests have failedHey @radadiyamohit81, TravisBuddy Request Identifier: 1b35a8f0-107d-11eb-af89-615b230ba186 |
ciphers/beaufort_cipher.py
Outdated
@@ -102,7 +49,7 @@ def cipherText(message: str, key_new: str) -> str: | |||
|
|||
# This function decrypts the encrypted text | |||
# and returns the original text | |||
def originalText(cipher_text: str, key_new: str) -> str: | |||
def original_text(cipher_text: str, key_new: str) -> str: | |||
""" | |||
>>> originalText("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> originalText("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") | |
>>> original_text("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! Thanks for your persistance.
Thank you so much @cclauss, looking forward to contributing more to your repository. |
* create beaufort cipher if you like my code, merge it and add the label as `hacktoberfest-accepted` * update the file * Update beaufort_cipher.py * Update beaufort_cipher.py * update as per black formatter * Update beaufort_cipher.py * update the file * update file * update file * update file * update file
* create beaufort cipher if you like my code, merge it and add the label as `hacktoberfest-accepted` * update the file * Update beaufort_cipher.py * Update beaufort_cipher.py * update as per black formatter * Update beaufort_cipher.py * update the file * update file * update file * update file * update file
* create beaufort cipher if you like my code, merge it and add the label as `hacktoberfest-accepted` * update the file * Update beaufort_cipher.py * Update beaufort_cipher.py * update as per black formatter * Update beaufort_cipher.py * update the file * update file * update file * update file * update file
if you like my code, merge it and add the label as
hacktoberfest-accepted
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.