I have a key for a cipher in the form "XY XY+1 XY+2 XY+3 XY+4 XY+5 FF FF" where XY is an unknown byte, for example, XY could be 00000000 so XY+1 is 00000001. Also, FF is a constant so always 11111111.
l have an addBinary() method which simply adds 1 to any binary string I give it, however, I'm finding it hard to generate all binary strings composing of "xxxx... 11111111 11111111".
I also found this printB() method on StackOverflow which generates the strings but just not sure how to hard code the FF's into it.
static void printB()
{
for(int i = 0; i < Math.pow(2,8); i++)
{
String format="%0"+8+"d";
System.out.printf(format,Integer.valueOf(Integer.toBinaryString(i)));
System.out.println();
}
}
Any help on how to generate this strings would be appreciated
assertEquals(makeString(0b10), "00000010 00000011 00000100 00000101 00000110 00000111 11111111 11111111")?0000 0000and then repeatedly adding1. Bitwise-add can, for example, be found here at StackOverflow. Alternatively useIntegerwith a radix of2(if performance does not matter that much), as seen here at SO. This approach allows you to simply dovalue++.