public void Sign(ISignable signable, string secret) { if (signable == null) { throw new SignatureException(nameof(signable)); } if (secret == null) { throw new SignatureException(nameof(secret)); } byte[] crypted = Crypt(signable.GetDataToSign(), secret); signable.Signature = Convert.ToBase64String(crypted); }
public bool Validate(ISignable signable, string secret) { if (signable == null) { throw new SignatureException(nameof(signable)); } if (secret == null) { throw new SignatureException(nameof(secret)); } byte[] crypted = Crypt(signable.GetDataToSign(), secret); var sign = Convert.ToBase64String(crypted); return(sign.Equals(signable.Signature)); }