/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Base32.cpp Date: 2021-6-12 Author: Reece ***/ #include #include "Base32.hpp" #include namespace Aurora::Parse { AUKN_SYM bool Base32Decode(const AuString &in, AuByteBuffer &decoded) { unsigned long length = in.size(); if (!AuTryResize(decoded, length)) { SysPushErrorMem(); return false; } auto status = base32_decode(in.data(), in.size(), reinterpret_cast(&decoded[0]), &length, BASE32_RFC4648); if (!AuTryResize(decoded, length)) { SysPushErrorMem(); return false; } return status == CRYPT_OK; } AUKN_SYM bool Base32Encode(const void *buffer, AuMach length, AuString &encoded) { unsigned long outLength = (length * 8 + 4) / 5; if (!AuTryResize(encoded, length)) { SysPushErrorMem(); return false; } auto status = base32_encode(reinterpret_cast(buffer), length, &encoded[0], &outLength, BASE32_RFC4648); if (!AuTryResize(encoded, length)) { SysPushErrorMem(); return false; } return status == CRYPT_OK; } }