from __future__ import annotations (#4763)

* from __future__ import annotations

* updating DIRECTORY.md

* from __future__ import annotations

* from __future__ import annotations

* Update xor_cipher.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss 2021-09-22 23:11:51 +02:00 committed by GitHub
parent dc07a85076
commit 15d1cfabb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 20 deletions

View File

@ -448,6 +448,7 @@
* [Find Min Recursion](https://github.com/TheAlgorithms/Python/blob/master/maths/find_min_recursion.py) * [Find Min Recursion](https://github.com/TheAlgorithms/Python/blob/master/maths/find_min_recursion.py)
* [Floor](https://github.com/TheAlgorithms/Python/blob/master/maths/floor.py) * [Floor](https://github.com/TheAlgorithms/Python/blob/master/maths/floor.py)
* [Gamma](https://github.com/TheAlgorithms/Python/blob/master/maths/gamma.py) * [Gamma](https://github.com/TheAlgorithms/Python/blob/master/maths/gamma.py)
* [Gamma Recursive](https://github.com/TheAlgorithms/Python/blob/master/maths/gamma_recursive.py)
* [Gaussian](https://github.com/TheAlgorithms/Python/blob/master/maths/gaussian.py) * [Gaussian](https://github.com/TheAlgorithms/Python/blob/master/maths/gaussian.py)
* [Greatest Common Divisor](https://github.com/TheAlgorithms/Python/blob/master/maths/greatest_common_divisor.py) * [Greatest Common Divisor](https://github.com/TheAlgorithms/Python/blob/master/maths/greatest_common_divisor.py)
* [Greedy Coin Change](https://github.com/TheAlgorithms/Python/blob/master/maths/greedy_coin_change.py) * [Greedy Coin Change](https://github.com/TheAlgorithms/Python/blob/master/maths/greedy_coin_change.py)

View File

@ -5,6 +5,7 @@ corresponding to the character's position in the alphabet.
https://www.dcode.fr/letter-number-cipher https://www.dcode.fr/letter-number-cipher
http://bestcodes.weebly.com/a1z26.html http://bestcodes.weebly.com/a1z26.html
""" """
from __future__ import annotations
def encode(plain: str) -> list[int]: def encode(plain: str) -> list[int]:

View File

@ -14,6 +14,7 @@ Module includes:
Created by TrapinchO Created by TrapinchO
""" """
from __future__ import annotations
RotorPositionT = tuple[int, int, int] RotorPositionT = tuple[int, int, int]
RotorSelectionT = tuple[str, str, str] RotorSelectionT = tuple[str, str, str]

View File

@ -1,4 +1,5 @@
# https://en.wikipedia.org/wiki/Trifid_cipher # https://en.wikipedia.org/wiki/Trifid_cipher
from __future__ import annotations
def __encryptPart(messagePart: str, character2Number: dict[str, str]) -> str: def __encryptPart(messagePart: str, character2Number: dict[str, str]) -> str:

View File

@ -16,6 +16,7 @@
- encrypt_file : boolean - encrypt_file : boolean
- decrypt_file : boolean - decrypt_file : boolean
""" """
from __future__ import annotations
class XORCipher: class XORCipher:
@ -41,17 +42,10 @@ class XORCipher:
key = key or self.__key or 1 key = key or self.__key or 1
# make sure key can be any size # make sure key is an appropriate size
while key > 255: key %= 255
key -= 255
# This will be returned return [chr(ord(ch) ^ key) for ch in content]
ans = []
for ch in content:
ans.append(chr(ord(ch) ^ key))
return ans
def decrypt(self, content: str, key: int) -> list[str]: def decrypt(self, content: str, key: int) -> list[str]:
""" """
@ -66,17 +60,10 @@ class XORCipher:
key = key or self.__key or 1 key = key or self.__key or 1
# make sure key can be any size # make sure key is an appropriate size
while key > 255: key %= 255
key -= 255
# This will be returned return [chr(ord(ch) ^ key) for ch in content]
ans = []
for ch in content:
ans.append(chr(ord(ch) ^ key))
return ans
def encrypt_string(self, content: str, key: int = 0) -> str: def encrypt_string(self, content: str, key: int = 0) -> str:
""" """