Debian Codegraph @

include/jwt/test/test_jwt_signature.cc

raw
1 #include <iostream>
2 #include "jwt/jwt.hpp"
3
4 void basic_sign_test()
5 {
6 // Create header
7 jwt::jwt_header hdr;
8 hdr = jwt::jwt_header{jwt::algorithm::HS256};
9
10 // Create payload
11 jwt::jwt_payload jp;
12 jp.add_claim("sub", "1234567890");
13 jp.add_claim("name", "John Doe");
14 jp.add_claim("admin", true);
15
16 jwt::jwt_signature sgn{"secret"};
17 std::error_code ec{};
18 auto res = sgn.encode(hdr, jp, ec);
19 std::cout << res << std::endl;
20 }
21
22 int main() {
23 basic_sign_test();
24 return 0;
25 }