Add handling for one more deviceID + misc optimization

This commit is contained in:
JustArchi
2019-02-15 21:20:44 +01:00
parent ca24138664
commit a00782527d
3 changed files with 16 additions and 5 deletions

View File

@@ -2238,7 +2238,7 @@ namespace ArchiSteamFarm {
text = text.Substring(keyIndex);
if ((text.Length != 32) || !Utilities.IsValidHexadecimalString(text)) {
if ((text.Length != 32) || !Utilities.IsValidHexadecimalText(text)) {
Bot.ArchiLogger.LogNullError(nameof(text));
return (ESteamApiKeyState.Error, null);

View File

@@ -303,7 +303,7 @@ namespace ArchiSteamFarm {
// Dashes are optional in the ID, strip them off for comparison
string hash = deviceID.Replace("-", "");
return (hash.Length > 0) && Utilities.IsValidHexadecimalString(hash);
return (hash.Length > 0) && (Utilities.IsValidDigitsText(hash) || Utilities.IsValidHexadecimalText(hash));
}
private string GenerateConfirmationHash(uint time, string tag = null) {
@@ -398,7 +398,7 @@ namespace ArchiSteamFarm {
uint fullCode = BitConverter.ToUInt32(bytes, 0) & 0x7fffffff;
// Build the alphanumeric code
StringBuilder code = new StringBuilder();
StringBuilder code = new StringBuilder(CodeDigits, CodeDigits);
for (byte i = 0; i < CodeDigits; i++) {
code.Append(CodeCharacters[fullCode % CodeCharacters.Length]);

View File

@@ -161,7 +161,18 @@ namespace ArchiSteamFarm {
}
[PublicAPI]
public static bool IsValidHexadecimalString(string text) {
public static bool IsValidDigitsText(string text) {
if (string.IsNullOrEmpty(text)) {
ASF.ArchiLogger.LogNullError(nameof(text));
return false;
}
return text.All(char.IsDigit);
}
[PublicAPI]
public static bool IsValidHexadecimalText(string text) {
if (string.IsNullOrEmpty(text)) {
ASF.ArchiLogger.LogNullError(nameof(text));
@@ -178,7 +189,7 @@ namespace ArchiSteamFarm {
string lastHex;
if (text.Length >= split) {
StringBuilder hex = new StringBuilder(split);
StringBuilder hex = new StringBuilder(split, 16);
foreach (char character in text) {
hex.Append(character);