Exemple #1
0
        private void RefreshCode()
        {
            long timestamp = Utils.GetSystemUnixTime();

            code = SteamAuth.GenerateSteamGuardCodeForTime(secret.SharedSecretString, timestamp);
            this.linkLabel1.Text = code;
        }
Exemple #2
0
        private void Initialize(object sender, EventArgs e)
        {
            // Check the file

            if (!File.Exists("config.json"))
            {
                linkLabel1.Text    = "Config first!";
                linkLabel1.Enabled = false;
                timer1.Enabled     = false;
                Utils.FileWrite(Application.StartupPath + "\\config.json", Json.stringify(new SharedSecret()));
                return;
            }

            // Check whether the code is valid

            secret = Json.parse <SharedSecret>(Utils.FileRead(Application.StartupPath + "\\config.json"));
            string code      = string.Empty;
            long   timestamp = Utils.GetSystemUnixTime();

            try
            {
                code = SteamAuth.GenerateSteamGuardCodeForTime(secret.SharedSecretString, timestamp);
            }
            catch (Exception)
            {
                code = "Secret invalid!";
                this.linkLabel1.Text = code;
                timer1.Enabled       = false;
                linkLabel1.Enabled   = false;
                progressBar1.Value   = 0;
                return;
            }

            // All the data check passed
            RefreshCode();
            timer1_Tick(sender, e);
        }