| 19 | * @returns {string} - `str` base64 encoded. |
| 20 | */ |
| 21 | export const hexToBase64 = str => |
| 22 | btoa( |
| 23 | String.fromCharCode.apply( |
| 24 | null, |
| 25 | str |
| 26 | .replace(/\r|\n/g, '') |
| 27 | .replace(/([\da-fA-F]{2}) ?/g, '0x$1 ') |
| 28 | .replace(/ +$/, '') |
| 29 | .split(' '), |
| 30 | ), |
| 31 | ) |
| 32 | |
| 33 | /** |
| 34 | * Converts base64 encoded string to hex. |
no test coverage detected