affineDecrypt accepts either null or undefined from modInv

This commit is contained in:
Barry Brown 2024-06-14 02:40:24 +00:00
parent 1017294942
commit e1e88c35ef

View file

@ -172,7 +172,7 @@ export function affineDecrypt(input, a, b, alphabet="a-z") {
const aInv = Utils.modInv(a, m);
const bInv = (m - b) % m;
if (aInv === null)
if (aInv === null || aInv === undefined)
throw new OperationError("The value of `a` (" + a + ") must be coprime to " + m + ".");
else return affineApplication(input, aInv, bInv, alphabet, decryptFn);
}