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..

没有正确的解决方案

其他提示

BigInteger has a toString() method, which gives a decimal string representation of the value.

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().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top