compat.jwt-cpp
#includejwt-cpp 0.7.2 — header-only JSON Web Token (JWT) library for C++, backed by OpenSSL
#include <jwt-cpp/jwt.h>
mcpp add compat.jwt-cpp@0.7.2
用法
來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。
// Behavioral test: HS256 sign -> decode -> verify through compat.openssl.
// The correct key and claim must pass; a wrong key must be rejected. This is
// the end-to-end assertion that the package's OpenSSL wiring actually links
// and computes, not just that headers exist.
#include <jwt-cpp/jwt.h>
#include <chrono>
#include <string>
int main() {
bool ok = true;
const auto token = jwt::create()
.set_payload_claim("sub", jwt::claim(std::string("alice")))
// Boolean claims need the JSON value spelled out: a
// bare `jwt::claim(true)` would need TWO user-defined
// conversions (bool -> picojson::value -> claim).
.set_payload_claim(
"admin",
jwt::claim(jwt::traits::kazuho_picojson::value_type(true)))
.set_expires_at(std::chrono::system_clock::now() +
std::chrono::seconds{3600})
.sign(jwt::algorithm::hs256{"secret-key"});
// …
tests/examples/jwt-cpp/tests/jwt.cpp · 專案 tests/examples/jwt-cpp
建置
- targets
jwt_cpp (lib)- language
c++20- import std
- no
- include dirs
*/include
原始檔 (1)
mcpp_generated/jwt_cpp_anchor.cpp
產生的檔案
mcpp_generated/jwt_cpp_anchor.cpp
版本
| 版本 | 平台 | 鏡像 | sha256 |
|---|---|---|---|
0.7.2 最新 |
LinuxWindowsmacOS | 來源 | 6e815d86c168… |