(string)
| 26 | } |
| 27 | |
| 28 | export function stringToHex(string) { |
| 29 | const encoder = new TextEncoder(); |
| 30 | const byteArray = encoder.encode(string); |
| 31 | let result = []; |
| 32 | |
| 33 | byteArray.forEach((value) => { |
| 34 | result.push(value.toString(16)); |
| 35 | }); |
| 36 | |
| 37 | return result.join('') |
| 38 | } |
| 39 | |
| 40 | export function binaryToHex(binary) { |
| 41 | return parseInt(binary, 2).toString(16); |