public bool InitializeEngine() { if (_algorithm == AlgorithmType.None) { return(false); } if (_algorithm == AlgorithmType.BlowFish || _algorithm == AlgorithmType.Des || _algorithm == AlgorithmType.Rc2 || _algorithm == AlgorithmType.Rijndael || _algorithm == AlgorithmType.TripleDes || _algorithm == AlgorithmType.Twofish) { _isSymmetric = true; _isHash = false; } else if (_algorithm == AlgorithmType.Md5 || _algorithm == AlgorithmType.Sha || _algorithm == AlgorithmType.Sha256 || _algorithm == AlgorithmType.Sha384 || _algorithm == AlgorithmType.Sha512) { _isSymmetric = false; _isHash = true; } _se = null; _he = null; switch (_algorithm) { case AlgorithmType.BlowFish: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.BlowFish); break; case AlgorithmType.Des: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.Des); break; case AlgorithmType.Md5: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.Md5); break; case AlgorithmType.Rc2: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.Rc2); break; case AlgorithmType.Rijndael: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.Rijndael); break; case AlgorithmType.Sha: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.Sha); break; case AlgorithmType.Sha256: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.Sha256); break; case AlgorithmType.Sha384: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.Sha384); break; case AlgorithmType.Sha512: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.Sha512); break; case AlgorithmType.TripleDes: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.TripleDes); break; case AlgorithmType.Twofish: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.Twofish); break; default: return(false); } return(true); }
private void DestroyEngine() { _se = null; _he = null; }
public bool DestroyEngine() { _se = null; _he = null; return(true); }
public bool InitializeEngine() { if (_algorithm == AlgorithmType.None) { return(false); } _isSymmetric = IsSymmetric(_algorithm); _isHash = IsHash(_algorithm); _se = null; _he = null; switch (_algorithm) { case AlgorithmType.BlowFish: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.BlowFish); break; case AlgorithmType.DES: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.DES); break; case AlgorithmType.MD5: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.MD5); break; case AlgorithmType.RC2: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.RC2); break; case AlgorithmType.Rijndael: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.Rijndael); break; case AlgorithmType.SHA: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.SHA); break; case AlgorithmType.SHA256: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.SHA256); break; case AlgorithmType.SHA384: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.SHA384); break; case AlgorithmType.SHA512: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.SHA512); break; case AlgorithmType.TripleDES: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.TripleDES); break; case AlgorithmType.Twofish: _se = new SymmetricAlgorithmEngine(SymmetricAlgorithmEngine.EncodeMethodEnum.Twofish); break; case AlgorithmType.Blake256: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.Blake256); break; case AlgorithmType.Blake512: _he = new HashAlgorithmEngine(HashAlgorithmEngine.EncodeMethodEnum.Blake512); break; default: return(false); } return(true); }
public void Setup() { _classUnderTest = new HashAlgorithmEngine(new SHA256Managed()); }