Mathematica Overflow[] error : Why and how-to bypass?

后端 未结 3 1796
清歌不尽
清歌不尽 2021-01-05 02:33

I never had an overflow error in Mathematica, the following happened.

I demo-ed the principle of RSA-encryption as follows:

 n = 11*13
 m = EulerPhi[         


        
3条回答
  •  清酒与你
    2021-01-05 03:15

    Try using PowerMod in the decyphering operation:

    n = 252097800611*252097800629;
    m = EulerPhi[n];
    e = 7;
    Print[GCD[e, m]];
    d = PowerMod[e, -1, m];
    Print[{"n" -> n, "m" -> m, "e" -> e, "d" -> d}];
    Grid[
     Join[{
      {"Input", "Encrypted", "Decrypt with Mod", "Decrypt with PowerMod"}}, 
      Table[{i, (j = Mod[i^e, n]), Mod[j^d, n], PowerMod[j, d, n]}, {i, 40}]], 
     Frame -> All]
    

提交回复
热议问题