Hill Cipher tests and info added

This commit is contained in:
n1073645 2020-02-14 10:46:29 +00:00
parent f46d9414cf
commit 34cd4af5f5
5 changed files with 69 additions and 6 deletions

View file

@ -203,6 +203,14 @@ export function encode(plaintext, key) {
// Generate matrix representation of the plaintext.
const plaintextMatrix = genMatrix(plaintext);
const det = determinant(keyMatrix, N);
if ((det % 2 === 0) || (det % 13 === 0))
throw new OperationError("Determinant has common factors with the modular base.");
if (det === 0)
throw new OperationError("Determinant is 0");
return join(multiply(keyMatrix, plaintextMatrix));
}