https://github.com/fernandolguevara/bech32.c3l
Bech32 encoding / decoding
https://github.com/fernandolguevara/bech32.c3l
bech32 bitcoin btc c3
Last synced: 4 months ago
JSON representation
Bech32 encoding / decoding
- Host: GitHub
- URL: https://github.com/fernandolguevara/bech32.c3l
- Owner: fernandolguevara
- Created: 2024-10-01T02:02:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-05T08:35:34.000Z (4 months ago)
- Last Synced: 2026-02-05T20:08:19.621Z (4 months ago)
- Topics: bech32, bitcoin, btc, c3
- Language: C3
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bech32 for c3
Library ported from bitcoinjs/bech32
## Example
```c++
import bech32;
fn void! main(String[] args) {
{
Decoded* decoded = bech32::bech32_decode("abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw")!;
assert(decoded.prefix == "abcdef");
assert(decoded.words == {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31});
char[] data = bech32::from_words(decoded.words)!;
String hex = data.bytes_to_hex();
assert( hex == "00443214c74254b635cf84653a56d7c675be77df");
char[] words = bech32::to_words("foobar")!!;
String b32 = bech32::bech32_encode("foo", words)!!;
io::printfn("bech32_encode %s", b32);
assert(b32 == "foo1vehk7cnpwgry9h96");
String b32m = bech32::bech32m_encode("foo", words)!!;
assert(b32m == "foo1vehk7cnpwgkc4mqc");
io::printfn("bech32m_encode %s", b32m);
};
```