lbry-desktop/ui/util/hex.js
2021-04-23 16:20:17 -04:00

10 lines
242 B
JavaScript

// @flow
export function toHex(str: string): string {
let s = unescape(encodeURIComponent(str));
let result = '';
for (let i = 0; i < s.length; i++) {
result += s.charCodeAt(i).toString(16).padStart(2, '0');
}
return result;
}