Actually be smarter

This commit is contained in:
Archi 2021-10-14 00:25:41 +02:00
parent 1456efc341
commit 14bab623b8
No known key found for this signature in database
GPG key ID: 6B138B4C64555AEA

View file

@ -166,6 +166,12 @@ namespace ArchiSteamFarm.Helpers {
throw new ArgumentNullException(nameof(key));
}
if (!HasDefaultCryptKey) {
ASF.ArchiLogger.LogGenericError(Strings.ErrorAborted);
return;
}
Utilities.InBackground(
() => {
(bool isWeak, string? reason) = Utilities.TestPasswordStrength(key, ForbiddenCryptKeyPhrases);
@ -176,12 +182,14 @@ namespace ArchiSteamFarm.Helpers {
}
);
EncryptionKey = Encoding.UTF8.GetBytes(key);
HasDefaultCryptKey = false;
byte[] encryptionKey = Encoding.UTF8.GetBytes(key);
if (EncryptionKey.Length < MinimumRecommendedCryptKeyBytes) {
if (encryptionKey.Length < MinimumRecommendedCryptKeyBytes) {
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningTooShortCryptKey, MinimumRecommendedCryptKeyBytes));
}
HasDefaultCryptKey = encryptionKey.SequenceEqual(EncryptionKey);
EncryptionKey = encryptionKey;
}
private static string? DecryptAES(string encryptedString) {