10 lines
242 B
JavaScript
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;
|
|
}
|