Paweł Baczyński wrote:
By the way, Base64 is not the same as hexadecimal notation.
import java.math.BigInteger;
public final class Temp {
public static void main(String args[]) {
BigInteger output = new BigInteger("53ABA93B9131C439D2942C7CBC483FA5", 16);
String value = output.toString();
System.out.println(value);
}
}
Tushar Goel wrote:I checked with my senior, he gave me wrong output. The output from the bin2bn is "3158851493".
I have written small C code to have the same functionality as bin2bn is having (considered only positive case).
Here most important part is while loop. all work is done in their only.
The output is:
When i compare with my output only first 4 matches.. Rest are not matches. I understand that after 7 bit it is resetting the variable at line 30. So that changes i have to do
otherwise first 7 should match.
I also tried to use long instead of BigInteger as they using the same but still only first 4 matches, Rest are not matching.
Sorry that that can't be right. How can a 32 hex character number be represented by only 10 decimal digits?
How to you know it has the same functionality?
I'm at a loss as to what this is trying to prove! Since you are providing a hex number as argument I think you should be using BN_hex2bn() and not BN_dec2bn() !
Tushar Goel wrote:
Sorry that that can't be right. How can a 32 hex character number be represented by only 10 decimal digits?
It can.
Tushar Goel wrote:there are no error codes. It is working fine. No issue is coming..
Tushar Goel wrote:My real aim is to implement bin2bn equivalence in java so that i can get the desired result. I have input in 16 byte bytes array and want
to convert it to the same as this method does.
Tushar Goel wrote:Not RSA. FPE(Format preserving encryption). It is new algorithm.
Tushar Goel wrote:Our tech team wrote this. Sorry i can't share the code. It is confidential.
If you see the output of bin2bn() it is "3158871461" where as input is "53 AB A9 3B 91 31 C4 39 D2 94 2C 7C BC 48 3F A5". If i add print statement in while method
present in the method then it will show all the iteration output and final output i pasted earlier. And if i passed the same input in BigInteger constructors then answer
doesn't match. I know may be i am doing something wrong but i can't figured it out.
I hope i am clear now.
Tushar Goel wrote:I have tried to use bn_hex2bn method as well as suggested by others and it returns the same output as bin2bn returns.
output:
number = 3158851493
You need to use BN_bn2dec()
Tushar Goel wrote:
Can you please tell me if i have to convert Java output to the C output how can i do that? I have to give the output in same format as C output is.
Tushar Goel wrote:Yes it is longer than 32 bit. Decimal value i am getting is "111217238859577568889117274385450287013".
I also wanted to ask why it is more than
32 bits? Doesn't understand the logic behind.
Tushar Goel wrote:Yeah thanks Richard. I am able to achieve this but can we transfer decimal output "111217238859577568889117274385450287013" into "3158851493" which
is bignum output.
I understand both are same but in different format but can we changed decimal output to bignum output format.
Campbell says..
We have spent all week trying to explain to you that the decimal number
Campbell says..
System.out.printf("The bottom 32 bits of i unsigned are %d%n", i.longValue() << 0x20 >>> 0x20);
Richard says..
OK the code used might be proprietary but the actual algorithm of any encryption technique should never be.
Richard says..
If your technical people have been using this in the generation of format preserving encryption then they need to be shot.
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|