+ 1

Conversion of String(text) to BigInteger and reversal(i.e. getting back the text in order)

i am implementing the rsa algorithm, since we have to deal with very large nos, i am using bigInteger datatype. it works fine with numbers but now i will have to test it for strings, how will i cast string to bigInteger and then get back the string....

11th Jul 2017, 9:59 AM
Naveed Jeelani Khan
Naveed Jeelani Khan - avatar
4 odpowiedzi
+ 1
BigInteger has a constructor that takes a String, and one that takes a String and radix (if you're using other than decimal numbers). It also has a toString() method that returns a decimal representation of the BigInteger. https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html Hope this helps!
17th Jul 2017, 2:49 PM
marit vandijk
+ 1
Alternatively, you could use Character.isDigit () method on each character in the String to see it its a digit?
18th Jul 2017, 1:34 PM
marit vandijk
0
Thank You...It helps but when characters are there in string, it passes them as BigInteger which produces error. However i have now first converted string to byte array then to byte string and passed as you said...It works!
18th Jul 2017, 11:05 AM
Naveed Jeelani Khan
Naveed Jeelani Khan - avatar