mirror of
https://github.com/torproject/collector.git
synced 2024-11-23 17:39:45 +00:00
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:
parent
2164508420
commit
f3b4636632
@ -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";
|
||||||
|
Loading…
Reference in New Issue
Block a user