示例#1
0
        /// <summary>
        /// 验证签名。
        /// </summary>
        /// <param name="source">要签名的数据。</param>
        /// <param name="signature"><paramref name="source"/> 的签名数据。</param>
        /// <returns></returns>
        public override bool VerifySignature(byte[] source, byte[] signature)
        {
            rsa.FromXmlString(PublicKey);
            var md5 = CryptographyFactory.Create(CryptoAlgorithm.MD5);

            return(rsa.VerifyHash(md5.Encrypt(source), "MD5", signature));
        }
示例#2
0
        /// <summary>
        /// 对数组进行签名。
        /// </summary>
        /// <param name="source">要签名的数据。</param>
        /// <returns></returns>
        public override byte[] CreateSignature(byte[] source)
        {
            rsa.FromXmlString(PrivateKey);
            var md5 = CryptographyFactory.Create(CryptoAlgorithm.MD5);

            return(rsa.SignHash(md5.Encrypt(source), "MD5"));
        }
示例#3
0
        /// <summary>
        /// 设置加解密的密钥。
        /// </summary>
        /// <param name="key"></param>
        public virtual void SetKey(string key)
        {
            var sourceArray = CryptographyFactory.Create(CryptoAlgorithm.MD5).Encrypt(key, Encoding.GetEncoding(0));

            CryptKey = new byte[8];
            CryptIV  = new byte[8];
            Array.Copy(sourceArray, 0, this.CryptKey, 0, 8);
            Array.Copy(sourceArray, 8, this.CryptIV, 0, 8);
        }
示例#4
0
        public override void SetKey(string key)
        {
            var sourceArray = CryptographyFactory.Create(CryptoAlgorithm.MD5).Encrypt(key, Encoding.GetEncoding(0));

            CryptKey = new byte[32];
            CryptIV  = new byte[16];

            Array.Copy(sourceArray, 0, CryptKey, 0, 16);
            sourceArray = Xor(sourceArray, 158, 16);
            Array.Copy(sourceArray, 0, CryptKey, 16, 16);
            sourceArray = Xor(sourceArray, 73, 16);
            Array.Copy(sourceArray, 0, CryptIV, 0, 16);
        }
示例#5
0
        public override void SetKey(string key)
        {
            var sourceArray = CryptographyFactory.Create(CryptoAlgorithm.MD5).Encrypt(key, Encoding.GetEncoding(0));

            CryptKey = new byte[24];
            CryptIV  = new byte[8];

            Array.Copy(sourceArray, 0, CryptKey, 0, 8);
            sourceArray = Xor(sourceArray, 62, 8);
            Array.Copy(sourceArray, 0, CryptKey, 8, 8);
            sourceArray = Xor(sourceArray, 216, 8);
            Array.Copy(sourceArray, 0, CryptKey, 16, 8);
            Array.Copy(sourceArray, 8, CryptIV, 0, 8);
        }