Debian Codegraph @

examples/simple_ex1.cc

raw
1 #include <iostream>
2 #include "jwt/jwt.hpp"
3
4 int main() {
5 using namespace jwt::params;
6
7 auto key = "secret"; //Secret to use for the algorithm
8 //Create JWT object
9 jwt::jwt_object obj{algorithm("HS256"), payload({{"some", "payload"}}), secret(key)};
10
11 //Get the encoded string/assertion
12 auto enc_str = obj.signature();
13 std::cout << enc_str << std::endl;
14
15 //Decode
16 auto dec_obj = jwt::decode(enc_str, algorithms({"HS256"}), secret(key));
17 std::cout << dec_obj.header() << std::endl;
18 std::cout << dec_obj.payload() << std::endl;
19
20 return 0;
21 }