AS3的BigInteger返回一个不正确的答案

编程入门 行业动态 更新时间:2024-10-24 06:24:23
本文介绍了AS3的BigInteger返回一个不正确的答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想实现在Flash中的RSA加密程序。我看着与大数字的工作,发现在加密包中的BigInteger变种类型。我开始玩弄BigIntegers但我的输出是永远正确的答案。例如下面的code将输出5911时,答案应该是9409.关于此错误的任何投入将是巨大的。

VAR温度:BigInteger的=新的BigInteger(字符串(97)); 临时= temp.pow(2); 跟踪(temp.toString()); 输出= 5911

解决方案

我不知道你指的是,我该加密包虽然当时的 as3crypto ,但我不记得这是有一个 POW 方法,该方法具有签名implementions。但无论哪种方式,你永远要记住什么基础你正在处理的,哪些库是专为。

(97 16 ) 2 = 5911 16

您正在处理十六进制,不是小数,数字。

想那怪胎,是别致的T恤,上面写着有10种人,那些了解二进制和那些不。在这种情况下,10被假定为10 2 。这相当于2 10 。不合格的基地几乎都毁了每个人的一天。

I am trying to implement a RSA encryption program in flash. I looked into working with Big Numbers and found the BigInteger var type in the Crypto package. I started playing around with BigIntegers but my outputs are never the correct answer. For example the below code will output 5911 when the answer should be 9409. Any input about this error would be great.

var temp:BigInteger = new BigInteger(String(97)); temp = temp.pow(2); trace(temp.toString()); Output = 5911

解决方案

I'm not sure which crypto package you are referring to, I though it was as3crypto but I don't remember it's implementions having a pow method that has that signature. But either way, you always have to remember what base you are dealing with and what the library was designed for.

(9716)2 = 591116

You are dealing with hex, not decimal, numbers.

Think of that geek-is-chic tshirt that says "There are 10 kinds of people. Those that understand binary and those that don't". In that case "10" is assumed to be 102. Which equals 210. Unqualified bases almost always ruin everybodys day.

更多推荐

AS3的BigInteger返回一个不正确的答案

本文发布于:2023-11-30 04:07:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648662.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不正确   答案   BigInteger

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!