Skip to content

Repository files navigation

tokenator

Create tokens easily.

Installation

npm install @christopy/tokenator --save

Usage

// Import Tokenator.constTokenator=require("@christopy/tokenator");

Creating Tokens

The returned data is used after to check the Token

constmyNewToken=Tokenator.Create({data: "I'm a precious data",// The Token dataexpiration: "05/04/2019",// When the Token expires (default is 24H)},"A super secure key"// The key for the Token encryption (required));

Checking Tokens

To check Tokens, your Id is used for it. The id is returned from the Tokenator.Create () function.
If the Id is wrong or the key couldn't decrypt the Token correctly, it returns null. If the Token is invalid or doesn't exists, it returns false. If the Token is valid, it returns true.

Tokenator.Check(myNewToken,"A super secure key");

Why web tokens?

Sometimes to learn something you need make your own implementation.

Version

1.0.4

About

Generate tokens easily

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages