コード例 #1
0
        public static string GetDescryptography(eTypeCryptography typeCryptography, string content, string key = null)
        {
            string cryptography = string.Empty;

            try
            {
                if (Validate(typeCryptography, content, key))
                {
                    switch (typeCryptography)
                    {
                    case eTypeCryptography.DES:
                        cryptography = DESCripto.ToDescrypt(key, content);
                        break;

                    case eTypeCryptography.AES:
                        cryptography = AESCripto.ToDescrypt(key, content);
                        break;

                    case eTypeCryptography.SHA256:
                    case eTypeCryptography.MD5:
                        throw new Exception("Este algoritmo não permite descriptografia.");

                    case eTypeCryptography.ZenitPolar:
                        cryptography = Zenit_Polar.ToDescript(content);
                        break;

                    case eTypeCryptography.RSA:
                        cryptography = RSACripto.Decrypt(content);
                        break;
                    }
                }

                return(cryptography);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                cryptography = string.Empty;
            }
        }