Skip to content

artinnok/nsjwt

 
 

Repository files navigation

nsjwt

https://secure.travis-ci.org/cordalace/nsjwt.svg?branch=master

No Shit JWT implementation

Advantages:

  • Damn simple: only HMAC SHA-256 ("HS256") algorithm implemented so no header parameter needed
  • Fast: uses ultrajson and pybase64
  • No Object-Oriented shit

Installation

pip install nsjwt

Usage

>>> import nsjwt
>>> secret = 'secret'
>>> payload = {"sub": "1234567890", "name": "Robbie Basho", "admin": True}

>>> nsjwt.encode(secret, payload)
b'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlJvYmJpZSBCYXNobyIsImFkbWluIjp0cnVlfQ.MvN07jU4TCXH-lrYE2qsiY5cmxHO7ZCH8eLn6WpbWFM'

>>> nsjwt.decode(secret, b'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRmFoZXkiLCJhZG1pbiI6dHJ1ZX0.XDADzzjyGLeoLBl2BHJaytkLtGdhBb5KWsKOtZlVEo8')
{'admin': True, 'name': 'John Fahey', 'sub': '1234567890'}

License

Apache 2.0 - See the LICENSE for more information.

About

No shit JWT implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%