mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-12-27 09:04:40 +01:00
4ffda340d3
And turn "" includes into full-path (which makes it easier to put config.h first, and finds some cases check-includes.sh missed previously). config.h sets _GNU_SOURCE which really needs to be done before any '#includes': we mainly got away with it with glibc, but other platforms like Alpine may have stricter requirements. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
26 lines
660 B
C
26 lines
660 B
C
#include "config.h"
|
|
#include <ccan/str/base32/base32.h>
|
|
#include <common/base32.h>
|
|
|
|
/* We want lower-case conversion please */
|
|
static const char base32_lower[] = "abcdefghijklmnopqrstuvwxyz234567=";
|
|
|
|
char *b32_encode(const tal_t *ctx, const void *data, size_t len)
|
|
{
|
|
char *str = tal_arr(ctx, char, base32_str_size(len));
|
|
|
|
base32_chars = base32_lower;
|
|
base32_encode(data, len, str, tal_count(str));
|
|
return str;
|
|
}
|
|
|
|
u8 *b32_decode(const tal_t *ctx, const char *str, size_t len)
|
|
{
|
|
u8 *ret = tal_arr(ctx, u8, base32_data_size(str, len));
|
|
|
|
base32_chars = base32_lower;
|
|
if (!base32_decode(str, len, ret, tal_count(ret)))
|
|
return tal_free(ret);
|
|
return ret;
|
|
}
|