public static bool ValidateKeySize( EncryptionAlgorithm algID, int Lenght) { switch (algID) { case EncryptionAlgorithm.DES: DES des = new DESCryptoServiceProvider(); return des.ValidKeySize(Lenght); case EncryptionAlgorithm.Rc2: RC2 rc = new RC2CryptoServiceProvider(); return rc.ValidKeySize(Lenght); case EncryptionAlgorithm.Rijndael: Rijndael rj = new RijndaelManaged(); return rj.ValidKeySize(Lenght); case EncryptionAlgorithm.TripleDes: TripleDES tDes = new TripleDESCryptoServiceProvider(); return tDes.ValidKeySize(Lenght); default: throw new CryptographicException("Algorithm " + algID + " Not Supported!"); } }