mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-06-01 09:27:41 +00:00
Implement verify. Part 1
This commit is contained in:
parent
8277e2cbd3
commit
796abd6e65
10 changed files with 473 additions and 160 deletions
BIN
include/jwt/test/test_jwt_decode
Executable file
BIN
include/jwt/test/test_jwt_decode
Executable file
Binary file not shown.
27
include/jwt/test/test_jwt_decode.cc
Normal file
27
include/jwt/test/test_jwt_decode.cc
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <iostream>
|
||||
#include "jwt/jwt.hpp"
|
||||
|
||||
void basic_decode_test()
|
||||
{
|
||||
// Create header
|
||||
jwt::jwt_header hdr;
|
||||
hdr = jwt::jwt_header{jwt::algorithm::HS256};
|
||||
|
||||
// Create payload
|
||||
jwt::jwt_payload jp;
|
||||
jp.add_claim("sub", "1234567890");
|
||||
jp.add_claim("name", "John Doe");
|
||||
jp.add_claim("admin", true);
|
||||
|
||||
jwt::jwt_signature sgn{"secret"};
|
||||
auto res = sgn.encode(hdr, jp);
|
||||
std::cout << res << std::endl;
|
||||
|
||||
std::cout << "DECODE: \n";
|
||||
jwt::jwt_decode(res, "secret");
|
||||
}
|
||||
|
||||
int main() {
|
||||
basic_decode_test();
|
||||
return 0;
|
||||
}
|
|
@ -10,7 +10,7 @@ void test_basic_header()
|
|||
|
||||
std::string enc_str = hdr.base64_encode();
|
||||
std::cout << "Base64: " << enc_str << std::endl;
|
||||
std::cout << "Decoded: " << jwt::jwt_header::base64_decode(enc_str) << std::endl;
|
||||
std::cout << "Decoded: " << hdr.base64_decode(enc_str) << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue