The Wayback Machine - https://web.archive.org/web/20211120105454/https://github.com/TheAlgorithms/Python/pull/5356
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

a5/1 cipher added issue#4977 fixed #5356

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

a5/1 cipher added issue#4977 fixed #5356

wants to merge 1 commit into from

Conversation

@hemil26
Copy link

@hemil26 hemil26 commented Oct 16, 2021

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}.
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

reg_y = []
reg_z = []

def loading_registers(key):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: loading_registers. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function loading_registers

Please provide type hint for the parameter: key

k = k + 1
r = r + 1

def set_key(key):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: set_key. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function set_key

Please provide type hint for the parameter: key

return True
return False

def get_key():

Choose a reason for hiding this comment

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

Please provide return type hint for the function: get_key. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function get_key

def get_key():
return key_one

def to_binary(plain):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: to_binary. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function to_binary

Please provide type hint for the parameter: plain

return binary_values


def get_majority(x,y,z): #gets majority by adding up the x,y,and z values and if it's greater than 1 (e.g. two 1's and one 0), it returns the majority (1). Otherwise, if it's two 0's and one 1, the majority is returned as 0.

Choose a reason for hiding this comment

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

Please provide return type hint for the function: get_majority. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function get_majority

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: x

Please provide type hint for the parameter: y

Please provide descriptive name for the parameter: y

Please provide type hint for the parameter: z

Please provide descriptive name for the parameter: z

i = i + 1
return convert_binary_to_str(str(s))

def user_input_key():

Choose a reason for hiding this comment

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

Please provide return type hint for the function: user_input_key. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function user_input_key

tha_key = str(input('Enter a 64-bit key: '))
return tha_key

def user_input_choice():

Choose a reason for hiding this comment

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

Please provide return type hint for the function: user_input_choice. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function user_input_choice

inp = str(input('[0]: Quit\n[1]: Encrypt\n[2]: Decrypt\nPress 0, 1, or 2: '))
return inp

def user_input_plaintext():

Choose a reason for hiding this comment

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

Please provide return type hint for the function: user_input_plaintext. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function user_input_plaintext

inp = str(input('Try again: '))
return inp

def user_input_ciphertext():

Choose a reason for hiding this comment

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

Please provide return type hint for the function: user_input_ciphertext. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function user_input_ciphertext

ciphertext = str(input('Enter a ciphertext: '))
return ciphertext

def tha_main():

Choose a reason for hiding this comment

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

Please provide return type hint for the function: tha_main. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file ciphers/a51.py, please provide doctest for the function tha_main

def user_input_plaintext():
try:
inp = str(input('Enter the plaintext: '))
except:
Copy link
Member

@cclauss cclauss Oct 18, 2021

Choose a reason for hiding this comment

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

binary = to_binary(plain)
keystream = get_keystream(len(binary))
i = 0
while(i < len(binary)):
Copy link
Member

@cclauss cclauss Oct 18, 2021

Choose a reason for hiding this comment

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

Suggested change
while(i < len(binary)):
while i < len(binary):

As discussed in CONTRIBUTING.md, psf/black will reformat the code here and elsewhere.

reg_x_length = 19
reg_y_length = 22
reg_z_length = 23

key_one = ""
reg_x = []
reg_y = []
reg_z = []
Copy link
Member

@cclauss cclauss Oct 18, 2021

Choose a reason for hiding this comment

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

Do we really need all these global?

import re
import copy
import sys
Copy link
Member

@cclauss cclauss Oct 18, 2021

Choose a reason for hiding this comment

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

Suggested change
import re
import copy
import sys
import copy
import re
import sys

Placate isort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment