Created
April 19, 2018 12:34
-
-
Save mratsim/b3b3ccf96fae413fc2fdaccb64d8d759 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func tohexBE[T: uint8 or uint16 or uint32 or uint64](x: T): string = | |
let bytes = cast[array[T.sizeof, byte]](x) | |
result = "" | |
for i in countdown(T.sizeof - 1, 0): | |
result.add toHex(bytes[i]) | |
func tohexBE(x: MpUintImpl): string = | |
const size = size_mpuintimpl(x) div 8 | |
let bytes = cast[array[size, byte]](x) | |
result = "" | |
for i in countdown(size - 1, 0): | |
result.add toHex(bytes[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment