So, Supposing I have the byte set
0101 0101 0110 0010 1101 0100 1111 0010 1011 0010 0101 1010
How would I do to get every byte independently? For example, printing them so the output is:
0101
0101
0110
0010
1101
0100
1111
1101
0010
1011
0010
0101
1010
Thanks a Lot!
Some Code:
protected String parse(StringBuilder builder) {
String pBinary = getBinary(p);
String qBinary = getBinary(q);
}
private String getBinary(BigInteger integer) {
StringBuilder builder = new StringBuilder();
for (byte bytes : integer.toByteArray()) {
builder.append(" ");
String binary = Integer.toBinaryString(Byte.toUnsignedInt(bytes));
if (binary.length() != 8)
for (int i = binary.length(); i < 8; i++)
builder.append(0);
builder.append(binary);
}
return builder.substring(1);
}
p and q are BigIntegers.
The idea is to insert at the start of the StringBuilder a "Mixture" of both binaries.
So if binary 1 is 01101001 01010111 and binary 2 is 10111010,
the mixture will result in 01101001 00000000 01010111 10111010