At the moment I am working on small RSA study project. I will not post most of code here as it is trivial. Here is some data:
const p - 43;
const q - 37;
const n - 1591;
const fi(n) - 1512;
const e - 611;
const d - 683;
let secretMessage = 1111;
console.log((secretMessage ** e) % n);
In this case I get NaN. As I understand the resulting integer is too big. How can I resolve this problem? I can`t code and encode message:
const secretMessage = 21;
const codedMessage = Math.pow(secretMessage, publicExponent) % n;
console.log(`coded message - ${codedMessage}`);
const uncodedMessage = Math.pow(codedMessage, secretExponent) % n;
console.log(`uncoded message - ${uncodedMessage}`);