JWS.SIGN

JWS.SIGN will sign the body of a JWT using a specified algorithm and signature. Unlike JWT.SIGN, JWS.SIGN will not try to encode its payload as JSON.

Xapix currently support the HS256, HS384, HS512 algorithms.

Function category: JWT

Syntax

JWS.SIGN(arg1, arg2, arg3, [args...])

Arguments

Description

arg1

String denoting the algorithm to be used.

arg2

Payload as a string to be used to generate a signature.

arg3

Signature to use in signing the JWT.

[args...]

Additional set of arguments for use with certain subsets of algorithms.

Examples

Example 1: Creating a JWT

If we want to create a JWT, we can use JWT.SIGN:

JWS.SIGN('HS256', "any + old + string", 'password')

This would use the provided algorithm and signature to create the following JWT:

eyJhbGciOiJIUzI1NiJ9.
YW55ICsgb2xkICsgc3RyaW5n.
OiCHe7w20NhTFov0gy3vcEp5HeD99KmvntOA9YwFank