Class Bytes


  • public class Bytes
    extends Object

    Bytes class.

    • Field Detail

      • TWO_WEEKS

        public static final Int TWO_WEEKS
        Constant TWO_WEEKS
    • Method Detail

      • lstrip

        public static byte[] lstrip​(byte[] bytes,
                                    byte bite)
        Strip leading
        Parameters:
        bytes - an array of byte objects
        bite - a byte
        Returns:
        an array of byte objects
      • strip

        public static byte[] strip​(byte[] bytes,
                                   byte bite)
        Strip trailing
        Parameters:
        bytes - an array of byte objects
        bite - a byte
        Returns:
        an array of byte objects
      • initFill

        public static byte[] initFill​(int length,
                                      byte filler)

        initFill.

        Parameters:
        length - a int
        filler - a byte
        Returns:
        an array of byte objects
      • add

        public static byte[] add​(byte[] a,
                                 byte[] b)

        add.

        Parameters:
        a - an array of byte objects
        b - an array of byte objects
        Returns:
        an array of byte objects
      • add

        public static byte[] add​(byte[][] bytesArray)

        add.

        Parameters:
        bytesArray - an array of byte objects
        Returns:
        an array of byte objects
      • changeOrder

        public static byte[] changeOrder​(byte[] bytes)
        Change the order from big to little endian and vice versa
        Parameters:
        bytes - an array of byte objects
        Returns:
        an array of byte objects
      • hexStringToByteArray

        public static byte[] hexStringToByteArray​(String s)

        hexStringToByteArray.

        Parameters:
        s - a String object
        Returns:
        an array of byte objects
      • byteArrayToHexString

        public static String byteArrayToHexString​(byte[] bytes)

        byteArrayToHexString.

        Parameters:
        bytes - an array of byte objects
        Returns:
        a String object
      • byteArrayToString

        public static String byteArrayToString​(byte[] bytes)

        byteArrayToString.

        Parameters:
        bytes - an array of byte objects
        Returns:
        a String object
      • bitsToTarget

        public static Int bitsToTarget​(byte[] bits)
        Turns bits into a target (large 256-bit integer)
        Parameters:
        bits - an array of byte objects
        Returns:
        a Int object
      • targetToBits

        public static byte[] targetToBits​(Int target)
        Turns a target integer back into bits, which is 4 bytes
        Parameters:
        target - a Int object
        Returns:
        an array of byte objects
      • calculateNewBits

        public static byte[] calculateNewBits​(byte[] previousBits,
                                              Int timeDifferential)
        Calculates the new bits given a 2016-block time differential and the previous bits
        Parameters:
        previousBits - an array of byte objects
        timeDifferential - a Int object
        Returns:
        an array of byte objects
      • bitFieldToBytes

        public static byte[] bitFieldToBytes​(byte[] bitField)

        bitFieldToBytes.

        Parameters:
        bitField - an array of byte objects
        Returns:
        an array of byte objects
      • bytesToBitField

        public static byte[] bytesToBitField​(byte[] someBytes)

        bytesToBitField.

        Parameters:
        someBytes - an array of byte objects
        Returns:
        an array of byte objects
      • xor

        public static byte[] xor​(byte[] b0,
                                 byte[] b1)

        xor.

        Parameters:
        b0 - a byte array
        b1 - a byte array
        Returns:
        an byte array
      • log

        @Deprecated(since="0")
        public static byte[] log​(byte[] bytes)
        Deprecated.
        temp use only

        log.

        Parameters:
        bytes - an array of byte objects
        Returns:
        an array of byte objects