Replies: 3 comments
-
Assuming you know your hex string corresponds to a multiple of five number of bits, I suppose the following would work : bech32 stake "$(
xxd -p -r <<<"e1876c8abaa636168c7d43623be103c6bfffcfb0337c05ffd1a7ea72e5" |
base32 |
tr A-Z2-7 "$bech32_charset" |
tr -d '\n='
)"
bech32_decode stake1uxrkez465cmpdrragd3rhcgrc6lllnasxd7qtl735l489egx9yfxe |
{
read
printf "%02x" $(convertbits 5 8 0)
echo
} I'm not sure what would happen if the hex string does not correspond to a multiple of five number of bits. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thx, let me try it. |
Beta Was this translation helpful? Give feedback.
0 replies
-
It works, for my usecase i have to blake2 the hex representation (one way bech conversion) before passing it further along, but it is coming to the same result: echo "Bash Bech32:"
bech32 asset "$(
xxd -p -r <<< "4dbf3aed7353c0901ee73b6deaef027c9f75a5f102c6346727cfe826746f6b656e72656774657374" |
b2sum -l 160 -b |
awk {'print $1'} |
xxd -p -r |
base32 |
tr A-Z2-7 "$bech32_charset" |
tr -d '\n='
)"
echo "Bech32 Binary:"
xxd -p -r <<< "4dbf3aed7353c0901ee73b6deaef027c9f75a5f102c6346727cfe826746f6b656e72656774657374" |
b2sum -l 160 -b |
awk {'print $1'} |
./bech32 asset Bash Bech32:
asset1utf8w3rj49jt93xy8qcl3j9p6dt34pcg5mqr66
Bech32 Binary:
asset1utf8w3rj49jt93xy8qcl3j9p6dt34pcg5mqr66 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
thank you for your work on porting the bech32 function to pure bash. Question, would it be possible to use this also for other blockchains?
I would like to use your bech32_encode/decode functions to rebuild the following:
In this example a precompiled external binary (bech32) was used to encode/decode between a bech32 string and the hex-representation. Would it be possible with your routines to achieve the same results somehow?
Best regards, Martin
Beta Was this translation helpful? Give feedback.
All reactions