Skip to content

Commit d060dda

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1655a82 commit d060dda

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

ciphers/hill_cipher.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def check_determinant(self) -> None:
2626
det = round(np.linalg.det(self.encrypt_key))
2727
if det < 0:
2828
det %= len(self.key_string)
29-
29+
3030
error_msg = f"Det {det} not coprime with 36. Try another key."
3131
if greatest_common_divisor(det, len(self.key_string)) != 1:
3232
raise ValueError(error_msg)
@@ -56,10 +56,10 @@ def make_decrypt_key(self) -> np.ndarray:
5656
det = round(np.linalg.det(self.encrypt_key))
5757
if det < 0:
5858
det %= len(self.key_string)
59-
59+
6060
# Find modular inverse of det
6161
det_inv = next(i for i in range(36) if (det * i) % 36 == 1)
62-
62+
6363
# Calculate inverse key
6464
inv_key = det_inv * np.linalg.det(self.encrypt_key) * np.linalg.inv(self.encrypt_key)
6565
return self.to_int(self.modulus(inv_key))
@@ -82,12 +82,12 @@ def main() -> None:
8282
n = int(input("Enter key order: "))
8383
print(f"Enter {n} rows of space-separated integers:")
8484
matrix = [list(map(int, input().split())) for _ in range(n)]
85-
85+
8686
hc = HillCipher(np.array(matrix))
87-
87+
8888
option = input("1. Encrypt\n2. Decrypt\nChoose: ")
8989
text = input("Enter text: ")
90-
90+
9191
if option == "1":
9292
print("Encrypted:", hc.encrypt(text))
9393
elif option == "2":

0 commit comments

Comments
 (0)