generate jwt token c# code example

Example 1: JASON WEB TOKENS EM VBNET COM WINDOWS FORMS

{
  "iss": "JwtServer",
  "sub": "hrmanager",
  "email": "hrmanager@xyz.com",
  "jti": "e971bd9c-7655-41d5-9c49-fabc054dc466",
  "iat": 1503922683,
  "http://schemas.microsoft.com/ws/2008/06/identity/claims/role": [
    "Employee",
    "HR-Worker",
    "HR-Manager"
  ],
  "Department": [
    "HR",
    "HR"
  ],
  "nbf": 1503922683,
  "exp": 1503924483
}

Example 2: conceito jwt em vbnet com exemplos

const crypto = require('crypto');

const header = JSON.stringify({
    'alg': 'HS256',
    'typ': 'JWT'
});

const payload = JSON.stringify({
    'email': 'aylan@boscarino.com',
    'password': 'ya0gsqhy4wzvuvb4'
});

const base64Header = Buffer.from(header).toString('base64').replace(/=/g, '');
const base64Payload = Buffer.from(payload).toString('base64').replace(/=/g, '');
const secret = 'my-custom-secret';

const data = base64Header + '.' + base64Payload;

const signature = crypto
    .createHmac('sha256', secret)
    .update(data)
    .digest('base64');

const signatureUrl = signature
    .replace(/\+/g, '-')
    .replace(/\//g, '_')
    .replace(/=/g, '')

console.log(signatureUrl);