Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Created September 1, 2021 06:44
Show Gist options
  • Save lotusirous/5ac6aff5864d9ddd82584cef302feaff to your computer and use it in GitHub Desktop.
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/)
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