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

后端 未结 3 1841
清歌不尽
清歌不尽 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:09

    Yes, you have gone through the limits of Mathematica. The maximum number that can be represented on a system in a particular version of Mathematica is shown by $MaxNumber. In your second example, d=18158086021982021938023 and hence 27136050989627^d is way way larger than $MaxNumber.

    You can use PowerMod in the second step too like you did for d, which will compute a^b mod n more efficiently than Mod. With decipher2[x_List] := FromCharacterCode[Map[PowerMod[#, d, n] &, x]], you get:

    cipher2["StackOverflow"]
    decipher2[cipher2["StackOverflow"]]
    
    Out[1]= {27136050989627, 282621973446656, 80798284478113, \
    93206534790699, 160578147647843, 19203908986159, 318547390056832, \
    107213535210701, 250226879128704, 114868566764928, 171382426877952, \
    207616015289871, 337931541778439}
    
    Out[2]= "StackOverflow"
    

提交回复
热议问题