Einhugur JWT Plugin |

# EinhugurJWT.Encode Method

Encodes JSON Web Token.

Encode(
params as EinhugurJWT.EncodingParameters) as String

#### Parameters

params
  Parameters to specify the claims.

#### Returns

String
  Encoded JSON Web token.

#### Remarks

This function can throw JWTException.
//Test and validate at: https://www.jwt.io/
try
var params as new EinhugurJWT.EncodingParameters()
params.Algorithm = EinhugurJWT.Algorithm.HS512
params.Subject = "Björn Eiríksson"
params.Issuer = "Einhugur"
params.Audience = "Administrator"
params.IssuedAt = EinhugurJWT.TimeSinceUnixEpoc()
params.Expiration = params.IssuedAt + 600 // Set to expire after 10 minutes (600 seconds).
params.SecretKey = "Some SupER s3kret HMAC keY"
// Add some custom claims
params.AddPayloadClaim("Test", "Someclaim", EinhugurJWT.ClaimType.StringClaim)
params.AddPayloadClaim("Test1", "Someclaim", EinhugurJWT.ClaimType.StringClaim)
params.AddPayloadClaim("Test2", "23", EinhugurJWT.ClaimType.IntegerClaim)
params.AddPayloadClaim("Test3", "23.0", EinhugurJWT.ClaimType.NumberClaim)
params.AddPayloadClaim("Test4", "null", EinhugurJWT.ClaimType.NullClaim)
params.AddPayloadClaim("Test5", "true", EinhugurJWT.ClaimType.BooleanClaim)
params.AddPayloadClaim("Test6", "[""Ford"", ""BMW"", ""Fiat""]", EinhugurJWT.ClaimType.ArrayClaim)
params.AddPayloadClaim("Test7", "{""name"":""John"", ""age"":30, ""city"":""New York""}", EinhugurJWT.ClaimType.ObjectClaim)
params.AddHeaderClaim("HeaderTest", "Someheaderclaim", EinhugurJWT.ClaimType.StringClaim)
TextArea1.Text = EinhugurJWT.Encode(params)
catch ex as EinhugurJWT.JWTException
MessageBox(ex.Message)
end try

#### Supported Platforms:

- macOS Intel 64 bit
- macOS Apple Silicon
- Windows 32 bit
- Windows 64 bit
- Windows ARM 64 bit
- Linux 32 bit
- Linux 64 bit
- Linux ARM 32 bit
- Linux ARM 64 bit
- iOS

#### See Also

EinhugurJWT Module