Skip to content

Commit e0fe4e7

Browse files
authored
Refactor CONSTANTS and littleEndianInt method
1 parent 5ad6dc5 commit e0fe4e7

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

‎src/main/java/com/thealgorithms/ciphers/ChaCha20.java‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ public final class ChaCha20 {
1414

1515
private static final int BLOCK_SIZE = 64;
1616
private static final long MAX_COUNTER = 0xFFFF_FFFFL;
17-
private static final int[] CONSTANTS = {
18-
0x61707865, 0x3320646e, 0x79622d32, 0x6b206574
19-
};
17+
private static final int[] CONSTANTS = {0x61707865, 0x3320646e, 0x79622d32, 0x6b206574};
2018

2119
private ChaCha20() {
2220
// Utility class
@@ -133,9 +131,6 @@ static void quarterRound(int[] state, int a, int b, int c, int d) {
133131
}
134132

135133
private static int littleEndianInt(byte[] bytes, int offset) {
136-
return (bytes[offset] & 0xFF)
137-
| ((bytes[offset + 1] & 0xFF) << 8)
138-
| ((bytes[offset + 2] & 0xFF) << 16)
139-
| ((bytes[offset + 3] & 0xFF) << 24);
134+
return (bytes[offset] & 0xFF) | ((bytes[offset + 1] & 0xFF) << 8) | ((bytes[offset + 2] & 0xFF) << 16) | ((bytes[offset + 3] & 0xFF) << 24);
140135
}
141136
}

0 commit comments

Comments
 (0)