public string CalculateSignature(string base64UrlEncodedHeader, string base64UrlEncodedPayload) { var input = $"{base64UrlEncodedHeader}{DefaultJwt.Separator}{base64UrlEncodedPayload}"; var hmac = new HmacGenerator(this.signingKey, Encoding.UTF8).ComputeHmac(input); return Base64.EncodeUrlSafe(hmac); }
private static byte[] SignHmac256(string data, byte[] key, Encoding encoding) { try { var hmac = new HmacGenerator(key, encoding); return hmac.ComputeHmac(data); } catch (Exception e) { throw new RequestAuthenticationException("Unable to calculate a request signature.", e); } }