我想实现在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返回一个不正确的答案
发布评论