squarealfa_security 3.2.0 copy "squarealfa_security: ^3.2.0" to clipboard
squarealfa_security: ^3.2.0 copied to clipboard

Package containing security-related features, like JWT token handling and password hashing.

example/example.dart

import 'package:squarealfa_security/squarealfa_security.dart';

void main(List<String> args) async {
  var secret = '62zb8Sky_i_2kNAKFkORRa42XlQK09Bdtl_GHkTN';

  // the JsonWebTokenHandler handles the generation and parsing of JWT tokens.
  var tokenGenerator = JsonWebTokenHandler(secret);

  // create the payload
  var claims = JwtPayload(
      name: 'John Doe',
      email: 'user@domain.com',
      subject: '5f35bd0489d72e2cd430f78d',
      issuer: 'Our Server',
      audience: 'Our Server',
      notBefore: DateTime.now(),
      expires: DateTime.now().add(Duration(seconds: 300)));

  // finally, generate the JWT token.
  var jwt = tokenGenerator.generate(claims);
  print('''The generated token is:
$jwt''');

  var payload = tokenGenerator.load(jwt);

  print('Name is ${payload.name}');
}
2
likes
0
pub points
53%
popularity

Publisher

verified publishersquarealfa.com

Package containing security-related features, like JWT token handling and password hashing.

Homepage
Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

crypto, cryptography, http, jose

More

Packages that depend on squarealfa_security