dim mykey as string = "secretkey"
dim part as string="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9"
log(getHashBase64(CreateHash(mykey,"HMACSHA256",part,"ASCII")))
Sub getHashBase64(inp As String) As String
Dim res As String = su.EncodeBase64(bc.HexToBytes(inp))
'URL safe, replace the chars
res=res.Replace("+","-")
res=res.Replace("/","_")
If res.EndsWith("=") Then ' remove padding
res = res.Replace("=","")
EndIf
Return res
EndSub
Sub CreateHash(key As String,algorithm As String,data As String,charset As String) As String
Dim m As Mac
Dim k AsKeyGenerator
Dim bc AsByteConverter
k.Initialize(algorithm)
k.KeyFromBytes(key.GetBytes(charset))
m.Initialise(algorithm, k.Key)
m.Update(data.GetBytes(charset))
Dim b() As Byte
b = m.Sign
Return bc.HexFromBytes(b)
EndSub