Encodes DataSource to a hexadecimal string.
Uses native Uint8Array.prototype.toHex if available, otherwise pure JS fallback.
Uint8Array.prototype.toHex
The DataSource to encode.
Hexadecimal string.
If the input is not a string, ArrayBuffer, or ArrayBufferView.
1.0.0
const hex = encodeHex(new Uint8Array([255, 0, 128]));console.log(hex); // 'ff0080'const hex2 = encodeHex('hello');console.log(hex2); // '68656c6c6f' Copy
const hex = encodeHex(new Uint8Array([255, 0, 128]));console.log(hex); // 'ff0080'const hex2 = encodeHex('hello');console.log(hex2); // '68656c6c6f'
Encodes DataSource to a hexadecimal string.
Uses native
Uint8Array.prototype.toHexif available, otherwise pure JS fallback.