Ejemplo n.º 1
0
        private string DecodePassword(string dbpassword, string salt, MembershipPasswordFormat?format)
        {
            switch (format ?? this.PasswordFormat)
            {
            case MembershipPasswordFormat.Clear:
            case MembershipPasswordFormat.Hashed:
                return(dbpassword);

            case MembershipPasswordFormat.Encrypted:
            {
                string result = string.Empty;
                if (this.EncryptionAlgorithm.ToUpper() == "DPAPI")
                {
                    result = EncryptionManager.DecryptDPAPI(dbpassword);
                }
                else
                {
                    if (!Enum.IsDefined(typeof(RijndaelSimpleHashAlgorithm), this.EncryptionAlgorithm))
                    {
                        throw new ProviderException("Encryption algorithm not valid. Possible values are " + DebugUtility.GetDebugString(typeof(RijndaelSimpleHashAlgorithm)) + " and DPAPI");
                    }
                    result = EncryptionManager.AES_Simple_Decrypt(dbpassword, this.PasswordPassphrase, salt, this.PasswordInitVector, (RijndaelSimpleHashAlgorithm)Enum.Parse(typeof(RijndaelSimpleHashAlgorithm), this.EncryptionAlgorithm), RijndaelSimpleKeySize.Medium, 3);
                }
                return(result);
            }

            default:
                throw new NotImplementedException(("MembershipPasswordFormat " + format) ?? (this.PasswordFormat + " not implemented."));
            }
        }