Package de.bsvrz.sys.funclib.srp6
Class BigIntegerUtils
- java.lang.Object
-
- de.bsvrz.sys.funclib.srp6.BigIntegerUtils
-
public class BigIntegerUtils extends java.lang.Object
Hexadecimal encoding and decoding utility.Obtained from Apache Xerces and Aduna Software code on java2s.com.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.math.BigInteger
bigIntegerFromBytes(byte[] bytes)
Converts a byte array to a positive BigIntegerstatic byte[]
bigIntegerToBytes(java.math.BigInteger bigInteger)
Converts a BigInteger into a byte array ignoring the sign of the BigInteger, according to RFC2945 specificationstatic java.math.BigInteger
fromHex(java.lang.String hex)
Decodes the specified hex string into a big integer.static java.lang.String
toHex(java.math.BigInteger bigint)
Encodes the specified big integer into a hex string.
-
-
-
Method Detail
-
toHex
public static java.lang.String toHex(java.math.BigInteger bigint)
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
public static java.math.BigInteger fromHex(java.lang.String hex)
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
public static java.math.BigInteger bigIntegerFromBytes(byte[] bytes)
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
public static byte[] bigIntegerToBytes(java.math.BigInteger bigInteger)
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.
-
-