コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }