projects
/
cipher-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Done challenge 6
[cipher-tools.git]
/
cipher
/
hill.py
diff --git
a/cipher/hill.py
b/cipher/hill.py
index 75048f9a52ddd3840ef19d614455de848f314153..8233de721231b5b4b2d1c2b3bafff982f48756e6 100644
(file)
--- a/
cipher/hill.py
+++ b/
cipher/hill.py
@@
-1,9
+1,10
@@
-from utilities import *
-from language_models import *
import multiprocessing
import numpy as np
from numpy import matrix
from numpy import linalg
import multiprocessing
import numpy as np
from numpy import matrix
from numpy import linalg
+from support.utilities import *
+from support.language_models import *
+from cipher.affine import modular_division_table
from logger import logger
from logger import logger
@@
-41,7
+42,7
@@
def hill_decipher(matrix, message, fillvalue='a'):
'hellothereaa'
"""
adjoint = linalg.det(matrix)*linalg.inv(matrix)
'hellothereaa'
"""
adjoint = linalg.det(matrix)*linalg.inv(matrix)
- inverse_determinant = modular_division_table[int(round(linalg.det(matrix))) % 26
][
1]
+ inverse_determinant = modular_division_table[int(round(linalg.det(matrix))) % 26
,
1]
inverse_matrix = (inverse_determinant * adjoint) % 26
return hill_encipher(inverse_matrix, message, fillvalue)
inverse_matrix = (inverse_determinant * adjoint) % 26
return hill_encipher(inverse_matrix, message, fillvalue)