Package de.bsvrz.sys.funclib.srp6
Class BigIntegerUtils
java.lang.Object
de.bsvrz.sys.funclib.srp6.BigIntegerUtils
Hexadecimal encoding and decoding utility.
Obtained from Apache Xerces and Aduna Software code on java2s.com.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigInteger
bigIntegerFromBytes
(byte[] bytes) Converts a byte array to a positive BigIntegerstatic byte[]
bigIntegerToBytes
(BigInteger bigInteger) Converts a BigInteger into a byte array ignoring the sign of the BigInteger, according to RFC2945 specificationstatic BigInteger
Decodes the specified hex string into a big integer.static String
toHex
(BigInteger bigint) Encodes the specified big integer into a hex string.
-
Method Details
-
toHex
Encodes the specified big integer into a hex string.- Parameters:
bigint
- the value to convert to a hexidecimal string- Returns:
- The resulting hex encoded string or
null
if the input is undefined.
-
fromHex
Decodes the specified hex string into a big integer.- Parameters:
hex
- The hex encoded string to decode.- Returns:
- The resulting big integer or
null
if decoding failed.
-
bigIntegerFromBytes
Converts a byte array to a positive BigInteger- Parameters:
bytes
- byte array in big endian unsigned RFC2945 format- Returns:
- positive BigInteger containing the data of the supplied byte array
-
bigIntegerToBytes
Converts a BigInteger into a byte array ignoring the sign of the BigInteger, according to RFC2945 specification- Parameters:
bigInteger
- BigInteger, must not be null, should not be negative- Returns:
- byte array (leading byte is always != 0), empty array if BigInteger is zero.
-