Add helpers for base64url encoding. base64url is a variant of base64 that uses a URL-safe alphabet. It can be constructed from base64 by replacing the '+' and '/' characters with '-' and '_' respectively. Many implementations also strip the padding, although this is not required by the spec [1]. This will be used in upcoming patches for Azure Key Vault requests that require base64url-encoded payloads. [1] https://datatracker.ietf.org/doc/html/rfc4648#section-5 Signed-off-by: Nikos Dragazis <nikolaos.dragazis@scylladb.com>
23 lines
470 B
C++
23 lines
470 B
C++
/*
|
|
* Copyright 2019-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string_view>
|
|
#include "bytes_fwd.hh"
|
|
|
|
std::string base64_encode(bytes_view);
|
|
std::string base64url_encode(bytes_view);
|
|
|
|
bytes base64_decode(std::string_view);
|
|
bytes base64url_decode(std::string_view);
|
|
|
|
size_t base64_decoded_len(std::string_view str);
|
|
|
|
bool base64_begins_with(std::string_view base, std::string_view operand);
|