예제 #1
0
        private System.Security.Cryptography.SymmetricAlgorithm CreateProvider(SymmetricAlgName algorithmName)
        {
            switch (algorithmName)
            {
            case SymmetricAlgName.AES:
                return(System.Security.Cryptography.Aes.Create());

            case SymmetricAlgName.DES:
                return(System.Security.Cryptography.DES.Create());

            case SymmetricAlgName.TripleDES:
                return(System.Security.Cryptography.TripleDES.Create());

            default:
                throw new NotSupportedException($"Unsupported symmetric algorithm '{algorithmName}'.");
            }
        }
예제 #2
0
 public SymmetricCrypto(SymmetricAlgName algorithmName)
 {
     this.AlgorithmName = algorithmName;
     this.provider      = CreateProvider(algorithmName);
 }