Code Monkey home page Code Monkey logo

jwtcpp's Introduction

JSON Web Tokens C++ lib

Warning

This library is a work in progress. It's not ready for production yet.

This lib exposes a simple class to work with signed JSON Web Tokens (JWT). It had been developped by Mozilla while making a C++ implementation of BrowserID.

JSON Web Tokens (JWT) are described in this document

Installation

Running make and make install should do the trick.

Dependencies

You need to have the following library installed on your system:

  • cryptopp for the crypto related stuff
  • jansson to deal with json

How to use it?

Once installed, jwtcpp provides a bunch of functions and methods so you can extract information about the JSON Web Tokens.

Here is an example application showing how you can use the library:

# include "jwtcpp.h"

using namespace std;

// It is possible to create a JWT from a string and to interact with it

JWT* jwt = JWT::fromString();
cout << jwt->algorithm << endl;
cout << jwt->signature << endl;
cout << jwt->signed_data << endl;

json_t* payload = jwt->payload;

// It is also possible to create a JWT programatically and then serialize
// it as a string
string serialized = jwt->generate(key);

// There is also a static method available if you want to directly
// serialize a mapping
Jwt* jwt = JWT::generate(mapping, key);

jwtcpp also provides a cli application able to generate and decode JWT. You can invoke it like this:

$ jwtcpp --generate --key=path/to/key.crt --data="{'json data': true}"
XXX the output here

$ jwtcpp --extract | cat token.jwt
XXX output

$ jwtcpp --extract --data "yourcontenthere"
XXX output

jwtcpp's People

Contributors

almet avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.