mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-15 02:26:54 -04:00
Hill Cipher tests and info added
This commit is contained in:
parent
f46d9414cf
commit
34cd4af5f5
5 changed files with 69 additions and 6 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue