Class BigIntegerUtils

java.lang.Object
de.bsvrz.sys.funclib.srp6.BigIntegerUtils

public class BigIntegerUtils extends Object
Hexadecimal encoding and decoding utility.

Obtained from Apache Xerces and Aduna Software code on java2s.com.

  • Method Details

    • toHex

      public static String toHex(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 BigInteger fromHex(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 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(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.