Skip to content
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

Merged
merged 11 commits into from
Oct 17, 2020
Merged

create beaufort cipher #3206

merged 11 commits into from
Oct 17, 2020

Conversation

radadiyamohit81
Copy link
Contributor

@radadiyamohit81 radadiyamohit81 commented Oct 11, 2020

if you like my code, merge it and add the label as hacktoberfest-accepted

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

if you like my code, merge it and add the label as `hacktoberfest-accepted`
@cclauss
Copy link
Member

cclauss commented Oct 17, 2020

Please run your code thru psf/black as discussed in CONTRIBUTING.md.

@cclauss
Copy link
Member

cclauss commented Oct 17, 2020

Comment on lines 69 to 70
>>> generate_key('THE GERMAN ATTACK','SECRET')
SECRETSECRETSECRE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> generate_key('THE GERMAN ATTACK','SECRET')
SECRETSECRETSECRE
>>> generate_key("THE GERMAN ATTACK", "SECRET")
'SECRETSECRETSECRE'

@TravisBuddy
Copy link

Travis tests have failed

Hey @radadiyamohit81,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: f23bf070-1073-11eb-af89-615b230ba186

@radadiyamohit81
Copy link
Contributor Author

Thank you @cclauss for helping me Thank you so much

Comment on lines 5 to 53
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def originalText(cipher_text: str, key_new: str) -> str:
def original_text(cipher_text: str, key_new: str) -> str:

Comment on lines 126 to 129
cipher_text = cipherText(message, key_new)
original_text = originalText(cipher_text, key_new)
print("Encrypted Text =", cipher_text)
print("Original Text =", original_text)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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...

@TravisBuddy
Copy link

Travis tests have failed

Hey @radadiyamohit81,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 1b35a8f0-107d-11eb-af89-615b230ba186

@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> originalText("BDC PAYUWL JPAIYI","SECRETSECRETSECRE")
>>> original_text("BDC PAYUWL JPAIYI","SECRETSECRETSECRE")

Copy link
Member

@cclauss cclauss left a 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.

@cclauss cclauss merged commit 3bbec1d into TheAlgorithms:master Oct 17, 2020
@radadiyamohit81
Copy link
Contributor Author

Thank you so much @cclauss, looking forward to contributing more to your repository.

stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* 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
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this pull request Apr 1, 2021
* 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
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants