[英]Java Big number negative?
I tried to get bignumber from a string, but the value in binary is wrong. 我试图从字符串中获取bignumber,但是二进制值是错误的。
priKeyData = HexByteKit.Hex2Byte("b8dfc598d14c0bb032c1f4eb1fcdb033289002f38cc16b2120dfa697f8982bef");
BigInteger priKeyBN2 = new BigInteger(priKeyData);
String s3 = priKeyBN2.toString(2);
it gives: -100011100100000001110100110011100101110101100111111010001001111110011010011111000001011000101001110000000110010010011111100110011010111011011111111110100001100011100110011111010010100110111101101111100100000010110010110100000000111011001111101010000010001 它给出了:-1000111001000000011101001100111001011101011001111110100010011111100110100111110000010110001010011100000001100100100100111111001100110101110110111111111111100001000011110011001111101001001001111111011011111001000000101100101101101000000000000
But the right one should be: 但是正确的应该是:
1011100011011111110001011001100011010001010011000000101110110000001100101100000111110100111010110001111111001101101100000011001100101000100100000000001011110011100011001100000101101011001000010010000011011111101001101001011111111000100110000010101111101111 10111000110111111100010110011000110100010100110000001011101100000011001011000001111101001110101100011111110011011011000000110011001010001001000000000010111100111000110011000001011010110010000100100000110111111010011010010111111110001001100000100110000010101111101111111
http://www.mobilefish.com/services/big_number/big_number.php http://www.mobilefish.com/services/big_number/big_number.php
The right one is 256 bit, so it overflows in Java bignumber class? 正确的是256位,所以它在Java bignumber类中溢出了? Then how can I use this 256 bit number for some steps in Java encryption algorithm?
那么,如何在Java加密算法的某些步骤中使用此256位数字呢?
Thanks. 谢谢。
I don't know what HexByteKit
is, but constructing BigInteger
from the hex string gives the right result: 我不知道
HexByteKit
是什么,但是从十六进制字符串构造BigInteger
可以得到正确的结果:
BigInteger priKeyBN2 = new BigInteger("b8dfc598d14c0bb032c1f4eb1fcdb033289002f38cc16b2120dfa697f8982bef", 16);
String s3 = priKeyBN2.toString(2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.