-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid using 1.0 Nimiq lib for transaction handling
- Loading branch information
Showing
5 changed files
with
85 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export function hexToBytes(hex: string) { | ||
return new Uint8Array((hex.match(/.{2}/g) || []).map(byte => parseInt(byte, 16))); | ||
} | ||
|
||
export function bytesToHex(bytes: Uint8Array) { | ||
const HEX_ALPHABET = '0123456789abcdef'; | ||
|
||
let hex = ''; | ||
for (let i = 0; i < bytes.length; i++) { | ||
const code = bytes[i]; | ||
hex += HEX_ALPHABET[code >>> 4]; | ||
hex += HEX_ALPHABET[code & 0x0F]; | ||
} | ||
return hex; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters