Created
February 15, 2022 15:27
-
-
Save bravo-kernel/3e7e5fe51aa2b68a2a24013be047ffa0 to your computer and use it in GitHub Desktop.
Convert bytes array to hex in Javascript
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
/** | |
* Converts a bytes array into a hex string. | |
* | |
* @see {@link https://stackoverflow.com/a/34310051/9850103} | |
* @param bytes - Array with bytes | |
*/ | |
export const bytesToHex = (bytes: Array<number>) => { | |
return Array.from(bytes, function (byte) { | |
return ("0" + (byte & 0xff).toString(16)).slice(-2) | |
}).join("") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment