sign

signs the given data with the secret using the given algorithm

string
sign
(
string secret
,
string data
,)

Parameters

secret string

the secret used to sign the data

data string

the data that is to be signed

alg JWTAlgorithm

the algorithm to be used to sign the data

Return Value

Type: string

signature of the data

Examples

string secret = "supersecret";

string data = "an unstoppable force crashes into an unmovable body";

string signature = sign(secret, data, JWTAlgorithm.HS512);

assert(signature.length > 0);

signature = sign(secret, data, JWTAlgorithm.NONE);

assert(signature.length == 0);

Meta