summaryrefslogtreecommitdiffstats
path: root/src/common/base64.h
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/common/base64.h
Add the files
Diffstat (limited to 'src/common/base64.h')
-rw-r--r--src/common/base64.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/base64.h b/src/common/base64.h
new file mode 100644
index 0000000..d17da5c
--- /dev/null
+++ b/src/common/base64.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "fastfetch.h"
+
+void ffBase64EncodeRaw(uint32_t size, const char* str, uint32_t* out_size, char* output);
+static inline FFstrbuf ffBase64EncodeStrbuf(const FFstrbuf* in) {
+ FFstrbuf out = ffStrbufCreateA(10 + in->length * 4 / 3);
+ ffBase64EncodeRaw(in->length, in->chars, &out.length, out.chars);
+ assert(out.length < out.allocated);
+
+ return out;
+}
+
+bool ffBase64DecodeRaw(uint32_t size, const char* str, uint32_t* out_size, char* output);
+static inline FFstrbuf ffBase64DecodeStrbuf(const FFstrbuf* in) {
+ FFstrbuf out = ffStrbufCreateA(10 + in->length * 3 / 4);
+ ffBase64DecodeRaw(in->length, in->chars, &out.length, out.chars);
+ assert(out.length < out.allocated);
+
+ return out;
+}