Package ch.bitagent.bitcoin.lib.helper
Class Bytes
- java.lang.Object
-
- ch.bitagent.bitcoin.lib.helper.Bytes
-
public class Bytes extends Object
Bytes class.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static byte[]add(byte[][] bytesArray)add.static byte[]add(byte[] a, byte[] b)add.static byte[]bitFieldToBytes(byte[] bitField)bitFieldToBytes.static IntbitsToTarget(byte[] bits)Turns bits into a target (large 256-bit integer)static StringbyteArrayToHexString(byte[] bytes)byteArrayToHexString.static StringbyteArrayToString(byte[] bytes)byteArrayToString.static byte[]bytesToBitField(byte[] someBytes)bytesToBitField.static byte[]calculateNewBits(byte[] previousBits, Int timeDifferential)Calculates the new bits given a 2016-block time differential and the previous bitsstatic byte[]changeOrder(byte[] bytes)Change the order from big to little endian and vice versastatic byte[]hexStringToByteArray(String s)hexStringToByteArray.static byte[]initFill(int length, byte filler)initFill.static byte[]log(byte[] bytes)Deprecated.temp use onlystatic byte[]lstrip(byte[] bytes, byte bite)Strip leadingstatic byte[]randomBytes(int length)randomBytes.static byte[]read(ByteArrayInputStream stream, int len)read.static byte[]strip(byte[] bytes, byte bite)Strip trailingstatic byte[]targetToBits(Int target)Turns a target integer back into bits, which is 4 bytesstatic byte[]xor(byte[] b0, byte[] b1)xor.
-
-
-
Field Detail
-
TWO_WEEKS
public static final Int TWO_WEEKS
ConstantTWO_WEEKS
-
-
Method Detail
-
lstrip
public static byte[] lstrip(byte[] bytes, byte bite)Strip leading- Parameters:
bytes- an array ofbyteobjectsbite- a byte- Returns:
- an array of
byteobjects
-
strip
public static byte[] strip(byte[] bytes, byte bite)Strip trailing- Parameters:
bytes- an array ofbyteobjectsbite- a byte- Returns:
- an array of
byteobjects
-
initFill
public static byte[] initFill(int length, byte filler)initFill.
- Parameters:
length- a intfiller- a byte- Returns:
- an array of
byteobjects
-
add
public static byte[] add(byte[] a, byte[] b)add.
- Parameters:
a- an array ofbyteobjectsb- an array ofbyteobjects- Returns:
- an array of
byteobjects
-
add
public static byte[] add(byte[][] bytesArray)
add.
- Parameters:
bytesArray- an array ofbyteobjects- Returns:
- an array of
byteobjects
-
changeOrder
public static byte[] changeOrder(byte[] bytes)
Change the order from big to little endian and vice versa- Parameters:
bytes- an array ofbyteobjects- Returns:
- an array of
byteobjects
-
read
public static byte[] read(ByteArrayInputStream stream, int len)
read.
- Parameters:
stream- aByteArrayInputStreamobjectlen- a int- Returns:
- an array of
byteobjects
-
hexStringToByteArray
public static byte[] hexStringToByteArray(String s)
hexStringToByteArray.
- Parameters:
s- aStringobject- Returns:
- an array of
byteobjects
-
byteArrayToHexString
public static String byteArrayToHexString(byte[] bytes)
byteArrayToHexString.
- Parameters:
bytes- an array ofbyteobjects- Returns:
- a
Stringobject
-
byteArrayToString
public static String byteArrayToString(byte[] bytes)
byteArrayToString.
- Parameters:
bytes- an array ofbyteobjects- Returns:
- a
Stringobject
-
bitsToTarget
public static Int bitsToTarget(byte[] bits)
Turns bits into a target (large 256-bit integer)- Parameters:
bits- an array ofbyteobjects- Returns:
- a
Intobject
-
targetToBits
public static byte[] targetToBits(Int target)
Turns a target integer back into bits, which is 4 bytes- Parameters:
target- aIntobject- Returns:
- an array of
byteobjects
-
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 ofbyteobjectstimeDifferential- aIntobject- Returns:
- an array of
byteobjects
-
bitFieldToBytes
public static byte[] bitFieldToBytes(byte[] bitField)
bitFieldToBytes.
- Parameters:
bitField- an array ofbyteobjects- Returns:
- an array of
byteobjects
-
bytesToBitField
public static byte[] bytesToBitField(byte[] someBytes)
bytesToBitField.
- Parameters:
someBytes- an array ofbyteobjects- Returns:
- an array of
byteobjects
-
xor
public static byte[] xor(byte[] b0, byte[] b1)xor.
- Parameters:
b0- a byte arrayb1- a byte array- Returns:
- an byte array
-
randomBytes
public static byte[] randomBytes(int length)
randomBytes.
- Parameters:
length- a int- Returns:
- an array of
byteobjects
-
log
@Deprecated(since="0") public static byte[] log(byte[] bytes)
Deprecated.temp use onlylog.
- Parameters:
bytes- an array ofbyteobjects- Returns:
- an array of
byteobjects
-
-