/// <summary> /// 初始化HASH加密器. /// </summary> /// <param name="algorithmType">HASH加密算法类型.</param> /// <param name="key">HASH密钥. 可选.</param> /// <param name="saltEnabled">在HASH加密过程中, 是否采用加盐(Salt)处理. </param> /// <param name="saltLength">盐(Salt)的长度.</param> protected void initialize(Type algorithmType, ProtectedKey key, bool saltEnabled, int saltLength) { if (algorithmType == null) { throw new ArgumentNullException("algorithmType"); } if (!typeof(HashAlgorithm).IsAssignableFrom(algorithmType)) { throw new ArgumentException(Properties.Resources.ExceptionCreatingHashAlgorithmInstance, "algorithmType"); } this.algorithmType = algorithmType; this.key = key; this.saltEnabled = saltEnabled; this.saltLength = saltLength; }
/// <summary> /// 初始实例对象. /// </summary> /// <param name="algorithmType">对称加密算法类型.</param> /// <param name="key">对称加密密钥.</param> protected void initialize(Type algorithmType, ProtectedKey key) { if (algorithmType == null) { throw new ArgumentNullException("algorithmType"); } if (!typeof(SymmetricAlgorithm).IsAssignableFrom(algorithmType)) { throw new ArgumentException(Properties.Resources.ExceptionCreatingSymmetricAlgorithmInstance, "algorithmType"); } if (key == null) { throw new ArgumentNullException("key"); } this.key = key; this.algorithm = this.GetSymmetricAlgorithm(algorithmType); }