static void Sign(JoseWebSignature Signature, Key Key) {
Signature.ProtectHeader();
string Base64Protected = BaseConvert.ToBase64urlString(
Signature.Protected, false);
byte[] ByteBase64Protected = UTF8Encoding.UTF8.GetBytes(Base64Protected);
string Base64Payload = BaseConvert.ToBase64urlString(
Signature.Payload, false);
byte[] ByteBase64Payload = UTF8Encoding.UTF8.GetBytes(Base64Protected);
var Stream = new MemoryStream();
Stream.Write(ByteBase64Protected, 0, ByteBase64Protected.Length);
Stream.WriteByte((byte)'.');
Stream.Write(ByteBase64Payload, 0, ByteBase64Payload.Length);
Stream.Position = 0;
//var ByteStream = Stream.ToArray();
//for (int i = 0; i < ByteStream.Length; i++) {
// Console.Write("{0}, ", ByteStream[i]);
// }
var MAC = new HMACSHA256(Key.k);
Signature.Signature = MAC.ComputeHash(Stream);
}