문제

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