ArchiSteamFarm.CryptoHelper.Decrypt C# (CSharp) Метод

Decrypt() статический приватный Метод

static private Decrypt ( ECryptoMethod cryptoMethod, string encrypted ) : string
cryptoMethod ECryptoMethod
encrypted string
Результат string
        internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted)
        {
            if (string.IsNullOrEmpty(encrypted)) {
                ASF.ArchiLogger.LogNullError(nameof(encrypted));
                return null;
            }

            switch (cryptoMethod) {
                case ECryptoMethod.PlainText:
                    return encrypted;
                case ECryptoMethod.AES:
                    return DecryptAES(encrypted);
                case ECryptoMethod.ProtectedDataForCurrentUser:
                    return DecryptProtectedDataForCurrentUser(encrypted);
                default:
                    return null;
            }
        }

Usage Example

Пример #1
0
        internal static BotConfig Load(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                ASF.ArchiLogger.LogNullError(nameof(filePath));
                return(null);
            }

            if (!File.Exists(filePath))
            {
                return(null);
            }

            BotConfig botConfig;

            try {
                botConfig = JsonConvert.DeserializeObject <BotConfig>(File.ReadAllText(filePath));
            } catch (Exception e) {
                ASF.ArchiLogger.LogGenericException(e);
                return(null);
            }

            if (botConfig == null)
            {
                ASF.ArchiLogger.LogNullError(nameof(botConfig));
                return(null);
            }

            botConfig.ShouldSerializeSensitiveDetails = false;

            // Support encrypted passwords
            if ((botConfig.PasswordFormat != CryptoHelper.ECryptoMethod.PlainText) && !string.IsNullOrEmpty(botConfig.SteamPassword))
            {
                // In worst case password will result in null, which will have to be corrected by user during runtime
                botConfig.SteamPassword = CryptoHelper.Decrypt(botConfig.PasswordFormat, botConfig.SteamPassword);
            }

            // User might not know what he's doing
            // Ensure that he can't screw core ASF variables
            if (botConfig.GamesPlayedWhileIdle.Count <= ArchiHandler.MaxGamesPlayedConcurrently)
            {
                return(botConfig);
            }

            ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningTooManyGamesToPlay, ArchiHandler.MaxGamesPlayedConcurrently, nameof(botConfig.GamesPlayedWhileIdle)));

            HashSet <uint> validGames = new HashSet <uint>(botConfig.GamesPlayedWhileIdle.Take(ArchiHandler.MaxGamesPlayedConcurrently));

            botConfig.GamesPlayedWhileIdle.IntersectWith(validGames);
            botConfig.GamesPlayedWhileIdle.TrimExcess();

            return(botConfig);
        }
All Usage Examples Of ArchiSteamFarm.CryptoHelper::Decrypt