getToken static method

String getToken(
  1. String data,
  2. DateTime live,
  3. String secretKey
)

Implementation

static String getToken(String data, DateTime live, String secretKey) {
  String header = _ecnrypt(jsonEncode({
    "alg":"HS256","typ":"JWT"
  }), secretKey);

  String payload = _ecnrypt(jsonEncode({
    "data": data,
    "live": live.toIso8601String()
  }), secretKey);

  String signature = _ecnrypt(base64Url.encode(Hmac(sha256, utf8.encode(secretKey)).convert("$header.$payload".codeUnits).bytes), secretKey);

  return "$header.$payload.$signature";
}