Anyone know what follow code does?
the question is about follow operators: & and |,and 0xfc
salt[0] = (byte)((salt[0] & 0xfc) | (saltLen & 0x03));
salt[1] = (byte)((salt[1] & 0xf3) | (saltLen & 0x0c));
salt[2] = (byte)((salt[2] & 0xcf) | (saltLen & 0x30));
salt[3] = (byte)((salt[3] & 0x3f) | (saltLen & 0xc0));
Well the comment above explains what it’s doing, but if you’re looking for a breakdown of the operators:
andonsalt[i]and a hex number (the&operator).andonsalt[i]and a second hex number.
oron the result of steps 1 and 2 (the|operator).bytesalt[i]The result is what is noted in the comment block. The numbers of the format
0xc0and whatnot are in hexadecimal, which is base 16. I.e.c0in hex is equivalent to16*12 + 16*0 = 192in decimal. In hex, since you run out of digits at 9, you begin using letters. Thus, a=10, b=11, c=12, d=13, e=14, f=15, and f becomes the highest “digit” since you would move over by one place when you get to 16 (as 16 is the base).See also: