Created
September 1, 2021 06:44
-
-
Save lotusirous/5ac6aff5864d9ddd82584cef302feaff to your computer and use it in GitHub Desktop.
A helper function to convert a byte array to hex (source: https://mkyong.com/java/java-how-to-convert-bytes-to-hex/)
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
function toHex(bArr) { | |
var result = ""; | |
for (var i = 0; i < bArr.length; i++) { | |
let dec = bArr[i] & 0xff; | |
var hex = Java.use("java.lang.Integer").toHexString(dec); | |
if (hex.length % 2 == 1) { | |
hex = "0" + hex; | |
} | |
result += hex; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment