php fmod()与POW()一起使用时返回错误的值

发布于 2025-02-05 08:15:36 字数 387 浏览 1 评论 0原文

因此,我试图执行一个应该加密文本的公共私钥方程

= m^e mod n,

其中m是需要加密的,我尝试了很多不同的事物,并且它们都没有工作,但它们都可以

pow(20,37)%77;

返回0

fmod(pow(20,37), 77);

返回33返回33

20^37%77;

返回49我的最接近的是48的正确答案,

我似乎无法弄清楚什么是错误的,我认为这可能是一个浮点问题,但是当在JavaScript中执行相同的方程式和C#时,

如果有人可以帮助我, 它可以很好地解决它。或至少让我走上正确的轨道,这将不胜感激:)

So im trying to do a public private key equation which should be

Encrypted text = m^e mod n

where m is what needs to be encrypted ive tried alot of different things and none of them work

pow(20,37)%77;

this returns 0

fmod(pow(20,37), 77);

this returns 33

20^37%77;

this returns 49 which is the closests ive gotten to the correct answer of 48

i cant seem to figure out what is going wrong im assuming it might be a floating point issue but when doing this same equation in javascript and c# it works out perfect

if anyone could help me out or atleast get me on the right track that would be greatly appreciated :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文