cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
sha256.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 [caomengxuan666]
2
3#pragma once
4
5#include <openssl/sha.h>
6
7#include <array>
8#include <cstddef>
9#include <string>
10#include <string_view>
11
14
17
18namespace mcp::auth::openssl {
19
21inline core::Result<std::string> sha256_base64url(std::string_view data) {
22 std::array<unsigned char, SHA256_DIGEST_LENGTH> digest{};
23 SHA256(reinterpret_cast<const unsigned char*>(data.data()), data.size(),
24 digest.data());
25 return base64url_encode_bytes(digest.data(), digest.size());
26}
27
30 std::string_view access_token) {
31 return sha256_base64url(access_token);
32}
33
34} // namespace mcp::auth::openssl
JOSE base64url helpers shared by optional OpenSSL auth code.
Shared result and error primitives used by the public cxxmcp SDK.
tl::expected< T, Error > Result
Alias for the SDK result type.
Definition result.hpp:64
core::Result< std::string > sha256_base64url(std::string_view data)
Compute base64url(SHA-256(data)).
Definition sha256.hpp:21
core::Result< std::string > dpop_access_token_hash(std::string_view access_token)
Compute the RFC 9449 DPoP ath value for an access token.
Definition sha256.hpp:29