-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QueryCompiler: Use SHA-256 hash instead of String#hashCode on class body
- Loading branch information
1 parent
857b720
commit c5507b5
Showing
2 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending | ||
*/ | ||
package io.deephaven.util; | ||
|
||
public class ByteUtils { | ||
private static final char[] HEX_LOOKUP = new char[] { | ||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; | ||
|
||
public static String byteArrToHex(byte[] bytes) { | ||
// our output size will be exactly 2x byte-array length | ||
final char[] buffer = new char[bytes.length * 2]; | ||
|
||
for (int ii = 0; ii < bytes.length; ii++) { | ||
// extract the upper 4 bits | ||
buffer[ii << 1] = HEX_LOOKUP[(bytes[ii] >> 4) & 0xF]; | ||
// extract the lower 4 bits | ||
buffer[(ii << 1) + 1] = HEX_LOOKUP[bytes[ii] & 0xF]; | ||
} | ||
|
||
return new String(buffer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters