Added binary literals as cobertura only warns, but all the results are

computed correctly.
Rather have more readable code.  Test tools will have to adapt.
This commit is contained in:
iwakeh 2016-09-30 11:58:27 +02:00
parent 2164508420
commit f3b4636632

View File

@ -356,8 +356,8 @@ public class SanitizedBridgesWriter extends CollecTorMain {
byte[] secret = this.getSecretForMonth(month); byte[] secret = this.getSecretForMonth(month);
System.arraycopy(secret, 50, hashInput, 22, 33); System.arraycopy(secret, 50, hashInput, 22, 33);
byte[] hashOutput = DigestUtils.sha256(hashInput); byte[] hashOutput = DigestUtils.sha256(hashInput);
int hashedPort = ((((hashOutput[0] & 0xFF) << 8) int hashedPort = ((((hashOutput[0] & 0b1111_1111) << 8)
| (hashOutput[1] & 0xFF)) >> 2) | 0xC000; | (hashOutput[1] & 0b1111_1111)) >> 2) | 0b1100_0000_0000_0000;
return String.valueOf(hashedPort); return String.valueOf(hashedPort);
} else { } else {
return "1"; return "1";