BigInteger has a toString()
method, which gives a decimal string representation of the value.
How to convert BigInteger to String?
-
15-10-2022 - |
سؤال
I decrypted a data and got a BigInt and when I tried to convert it to string I got some Wired characters.
Code for getting BigInteger
BigInteger dec = process.Decrypt(sec);
Code for getting ByteArray
byte testBy[] = dec.toByteArray();
Code for Converting into String
String ss = new String(testBy);
System.out.println(ss);
and I tried this code too
String ss = new String(testBy);
System.out.println(ss, "UTF8");
I'm getting this output
=^ö½ß‡k+Éæ‚ûŽ3B‚+…Òæ?&¶?kÛUô—c
Help me out here..
لا يوجد حل صحيح
نصائح أخرى
A call to System.out.println(dec)
should print the decimal representation of dec
correctly.
So just make sure that BigInteger dec = process.Decrypt(sec)
yields the expected result.
toString()
method convert BigInteger to String.Actually it overrides the Object toString() method.Or directly pass BigInteger object to System.out.println() because println bydefault takes Object.toString().
لا تنتمي إلى StackOverflow