Class Base32
java.lang.Object
com.inductiveautomation.ignition.common.licensing.Base32
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
bitSetToByteArray
(BitSet bs, int numBits) This function will take a BitSet, whose byte order is LSB->MSB, and create a byte[] whose bytes are in the same order.static BitSet
Takes string s, which should be a number encoded in Base32.static String
encode
(byte[] bytes) This function will encode the byte array 'bytes' into a Base-32 formatted string using charactors 1-9, A-X, skipping zero and 'O'.static String
This function takes a BitSet, whose LSB is in position 0 and whose MSB is in position length-1, and turns it into a Base32 string whose endianness is opposite, MSB-LSB, similar to how one would write a hex string.static char
getChar
(int i) static boolean
ithBitSet
(byte b, int i)
-
Constructor Details
-
Base32
public Base32()
-
-
Method Details
-
encode
This function will encode the byte array 'bytes' into a Base-32 formatted string using charactors 1-9, A-X, skipping zero and 'O'. Note that if the number of bits (length*8) is not divisible by 5, then zeroes will be padded onto the MSB side of the intermediate BitSet. This means that when the resulting Base32 String is decoded, you may get an extra byte of all zeroes.- Parameters:
bytes
- an array of bytes. Note that the bytes in the lower indices will be treated as lower significance. So, {0xab, 0xcd, 0xef} will be the hex number 0xefcdab- Returns:
- a String encoding bytes in Base-32
-
encode
This function takes a BitSet, whose LSB is in position 0 and whose MSB is in position length-1, and turns it into a Base32 string whose endianness is opposite, MSB-LSB, similar to how one would write a hex string. -
decode
Takes string s, which should be a number encoded in Base32. Note that the string s has its LSB in the rightmost character, and the MSB in the leftmost char. For instance, s = ART3B7 MSB <-->LSB Note that this is similar to how one would write a hex number, i.e. 0xABCD- Returns:
- This function will return a BitSet which contains the binary number that s represents. The bitset will have its LSB at position 0, and its MSB at position length-1.
-
bitSetToByteArray
This function will take a BitSet, whose byte order is LSB->MSB, and create a byte[] whose bytes are in the same order. Note that the byte array may have more bits that the BitSet, as the length of the byte array in bits will be an even multiple of 8, whereas the length it bits of the BitSet will most likely be a multiple of 5. Hence, the last byte in the byte array will probably start with three zeroes.- Parameters:
bs
- the LSB->MSB bit set to convert.numBits
- The number of bits in the bit set to process.
-
ithBitSet
public static boolean ithBitSet(byte b, int i) -
getChar
public static char getChar(int i)
-