Last updated:
0 purchases
jwt token generator
A JWT token generator package for flutter and dart.
Features #
Generate HS256 algorithm jwt token.
Getting started #
Add the depency to pubspec.yaml and start using its methods.
Usage #
Instantiate JWT class.
Declare the payload.
Use generateToken method.
JWT jwt = JWT();
Map<String, dynamic> payload = {
'iss': 'localhost',
'exp': DateTime.now().add(Duration(hours: 1)).millisecondsSinceEpoch / 1000,
'id': 1,
'fullname': 'User name'
};
String token = await jwt.generateToken(payload: payload, secretKey: 'SampleKey');
copied to clipboard
To validate JWT #
Instantiate JWT class.
Use validate JWT method.
JWT jwt = JWT();
bool isValidated = await jwt.verifyTokey(token: token, secretKey: secretKey);
print(isValidated);// True or False
copied to clipboard
Additional information #
Currently supported algorithm: HS256
will be adding more algorithm soon or if you want to contribute you are welcome.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.