user1584314
user1584314

Reputation: 61

from byteArray to bigInteger

how to convert a byteArray to bigInteger? it's important to say than my bytearray is not the ordinay byte[].. its a class in my project. basically i have an array of 256 bytes and i need to represent it as BigInteger in order to perform a calculation .

the code looks like this:

//this is how i get my information in byteArray

  ByteArray modulus = (ByteArray)inParamsList.getParameterType("modulus");

//this is the line that i get an exception for. it happens because the "toString" doesn't actully converts it to string

  BigInteger modulusInBig = new BigInteger(modulus.toString());

i would be very happy to get some answers! i lookes all over the internet already...

Upvotes: 5

Views: 1384

Answers (1)

weston
weston

Reputation: 54781

Modify your ByteArray class to provide a toArrayByte() method, returning byte[] then:

BigInteger modulusInBig = new BigInteger(modulus.toArrayByte());

Upvotes: 2

Related Questions