made Encrypt() and Decrypt() actions return success boolean

This commit is contained in:
Carson McManus 2016-08-23 13:58:00 -04:00
parent 0b0331bcc0
commit 3a0c63b589

View file

@ -103,10 +103,10 @@ public static class Program
GenerateCode(user); GenerateCode(user);
break; break;
case "encrypt": // Can also be used to change passkey case "encrypt": // Can also be used to change passkey
Encrypt(); Console.WriteLine(Encrypt());
break; break;
case "decrypt": case "decrypt":
Decrypt(); Console.WriteLine(Decrypt());
break; break;
case "setup": case "setup":
throw new NotSupportedException(); throw new NotSupportedException();
@ -165,7 +165,7 @@ public static class Program
Console.WriteLine("error: No Steam accounts found in {0}", SteamGuardAccounts); Console.WriteLine("error: No Steam accounts found in {0}", SteamGuardAccounts);
} }
static void Encrypt() static bool Encrypt()
{ {
if (Verbose) Console.WriteLine("Opening manifest..."); if (Verbose) Console.WriteLine("Opening manifest...");
Manifest = Manifest.GetManifest(true); Manifest = Manifest.GetManifest(true);
@ -189,10 +189,12 @@ public static class Program
var iv = Manifest.GetInitializationVector(); var iv = Manifest.GetInitializationVector();
bool success = Manifest.SaveAccount(account, true, newPassKey, salt, iv); bool success = Manifest.SaveAccount(account, true, newPassKey, salt, iv);
if (Verbose) Console.WriteLine("Encrypted {0}: {1}", account.AccountName, success); if (Verbose) Console.WriteLine("Encrypted {0}: {1}", account.AccountName, success);
if (!success) return false;
} }
return true;
} }
static void Decrypt() static bool Decrypt()
{ {
if (Verbose) Console.WriteLine("Opening manifest..."); if (Verbose) Console.WriteLine("Opening manifest...");
Manifest = Manifest.GetManifest(true); Manifest = Manifest.GetManifest(true);
@ -205,7 +207,7 @@ public static class Program
else else
{ {
if (Verbose) Console.WriteLine("Decryption not required."); if (Verbose) Console.WriteLine("Decryption not required.");
return; return true;
} }
for (int i = 0; i < SteamGuardAccounts.Length; i++) for (int i = 0; i < SteamGuardAccounts.Length; i++)
@ -213,6 +215,8 @@ public static class Program
var account = SteamGuardAccounts[i]; var account = SteamGuardAccounts[i];
bool success = Manifest.SaveAccount(account, false); bool success = Manifest.SaveAccount(account, false);
if (Verbose) Console.WriteLine("Decrypted {0}: {1}", account.AccountName, success); if (Verbose) Console.WriteLine("Decrypted {0}: {1}", account.AccountName, success);
} if (!success) return false;
}
return true;
} }
} }