You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Utils.modInv function internally uses 26 as the modulus rather than the argument y. The bug is not externally visible because it's used in the Affine Decode operation, which uses an alphabet with 26 letters.
Source code
static modInv(x, y) {
x %= y;
for (let i = 1; i < y; i++) {
if ((x * i) % 26 === 1) {
return i;
}
}
}
Remedy
Replace 26 with y.
Better still: replace the entire function with one that uses the Extended Euclidean Algorithm to compute the modular multiplicative inverse. It will be faster than a brute-force loop for large values of y.
The text was updated successfully, but these errors were encountered:
Describe the bug
The Utils.modInv function internally uses 26 as the modulus rather than the argument
y
. The bug is not externally visible because it's used in the Affine Decode operation, which uses an alphabet with 26 letters.Source code
Remedy
Replace
26
withy
.Better still: replace the entire function with one that uses the Extended Euclidean Algorithm to compute the modular multiplicative inverse. It will be faster than a brute-force loop for large values of
y
.The text was updated successfully, but these errors were encountered: