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 |
| >>> generate_key('THE GERMAN ATTACK','SECRET') | ||
| SECRETSECRETSECRE |
There was a problem hiding this comment.
| >>> 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 |
| 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.
| 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!
|
|
||
| # 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.
| def cipherText(message: str, key_new: str) -> str: | |
| def cipher_text(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: |
There was a problem hiding this comment.
| def originalText(cipher_text: str, key_new: str) -> str: | |
| def original_text(cipher_text: str, key_new: str) -> str: |
| 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.
| 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 |
| 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.
| >>> originalText("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") | |
| >>> original_text("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") |
cclauss
left a comment
There was a problem hiding this comment.
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-acceptedDescribe your change:
Checklist:
Fixes: #{$ISSUE_NO}.