private void Form1_Activated(object sender, EventArgs e) { if (txtCode1.Text == "") { txtCode1.Text = OneTimePasswordUtil.RandomCode1().ToString(); } }
private void btnCheckCode_Click_1(object sender, EventArgs e) { if (!long.TryParse(txtCode1.Text, out long code1)) { txtCode1.Text = OneTimePasswordUtil.RandomCode1().ToString(); } if (!long.TryParse(txtCode2.Text, out long code2)) { txtCode2.Text = ""; txtCode2.Focus(); } if (!int.TryParse(txtMinutes.Text, out int minutes)) { txtMinutes.Text = ""; txtMinutes.Focus(); } if (OneTimePasswordUtil.IsValidV2(txtName.Text, minutes, code1, code2) || OneTimePasswordUtil.IsMasterCodeV2(txtName.Text, code1, code2)) { timer1.Enabled = true; txtCode1.Text = ""; txtCode2.Text = ""; timer1.Interval = 1000 * minutes * 60; // in milliseconds WindowState = FormWindowState.Minimized; } }