We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
arrayToHexString
1 parent 772d4ed commit 46a706fCopy full SHA for 46a706f
1 file changed
lib/utils.ts
@@ -54,12 +54,10 @@ export const hexStringToArray = (hex: string) => {
54
* @returns Hexadecimal representation of the array
55
*/
56
export const arrayToHexString = (bytes: Uint8Array) => {
57
- const res = [];
58
- for (let c = 0; c < bytes.length; c++) {
59
- const hex = bytes[c].toString(16);
60
- res.push(hex.length < 2 ? '0' + hex : hex);
61
- }
62
- return res.join('');
+ const hexAlphabet = '0123456789abcdef';
+ let s = '';
+ bytes.forEach((v) => { s += hexAlphabet[v >> 4] + hexAlphabet[v & 15]; });
+ return s;
63
};
64
65
/**
0 commit comments