protected void Button100_Click(object sender, EventArgs e) { string username = (string)Session["usernameLogin"]; string md5hash = (string)Session["md5Store"]; UserCustomer cu = new UserCustomer(); cu = cu.getAllDataByName(username); string salt = cu.Passwordsalt; string firstNameCipher = cu.FirstName; string lastNameCipher = cu.LastName; string nricCipher = cu.Nric; string phone = cu.PhoneNo; byte[] salttoByte = Convert.FromBase64String(salt); Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(md5hash, salttoByte); RijndaelManaged cipher = new RijndaelManaged(); //set key and initialisation vec from rfc cipher.Key = pdb.GetBytes(32); cipher.IV = pdb.GetBytes(16); ICryptoTransform decryptTransform = cipher.CreateDecryptor(); byte[] cipherphone = Convert.FromBase64String(phone); byte[] plaintextPhone = decryptTransform.TransformFinalBlock(cipherphone, 0, cipherphone.Length); string resultPhone = Encoding.UTF8.GetString(plaintextPhone); //save current date and time at the point of request DateTime timeofrequesttimeout = DateTime.Now.AddSeconds(30); System.Diagnostics.Debug.WriteLine(timeofrequesttimeout); Session["2faotptimeoutdatetimecheckthis"] = timeofrequesttimeout; Random rnd = new Random(); string digit = rnd.Next(999999).ToString(); Session["rngPhoneL"] = digit; System.Diagnostics.Debug.WriteLine(digit); //uncomment this string resPhone = "+65" + resultPhone; Tzwilio g = new Tzwilio(resPhone, digit); g.choasSms(); }
protected void Button2_OnClick(object sender, EventArgs e) { if (Session["phoneClickedRConf"] == null) { Session["phoneClickedRConf"] = "false"; } if (!Session["phoneClickedRConf"].ToString().Equals("true")) { DateTime otherDate = DateTime.Now.AddMinutes(1); Session["PotherDateTimeNow"] = otherDate; string phone = Session["nextPageUserRegPhone"].ToString(); System.Diagnostics.Debug.WriteLine(phone); Random rnd = new Random(); string digit = rnd.Next(999999).ToString(); Session["rngPhoneLPHHlUserReg"] = digit; string pdf = "+65" + Session["nextPageUserRegPhone"].ToString(); Tzwilio oi = new Tzwilio(pdf, "Otp is: " + digit); oi.choasSms(); System.Diagnostics.Debug.WriteLine("rr" + Session["nextPageUserRegPhone"].ToString()); Label2.Text = "Message sent"; Session["phoneClickedRConf"] = "true"; } else { DateTime otherdate = (DateTime)Session["PotherDateTimeNow"]; System.Diagnostics.Debug.WriteLine(otherdate); System.Diagnostics.Debug.WriteLine(DateTime.Now); bool d = otherdate < DateTime.Now; System.Diagnostics.Debug.WriteLine("check date" + d); if (otherdate < DateTime.Now) { DateTime otherDate = DateTime.Now.AddMinutes(1); // System.Diagnostics.Debug.WriteLine("rr" + Session["nextPageUserRegEMail"].ToString()); Random rnd = new Random(); string digit = rnd.Next(999999).ToString(); Session["rngPhoneLPHHlUserReg"] = digit; string pfdd = "+65" + Session["nextPageUserRegPhone"].ToString(); Tzwilio ds = new Tzwilio(pfdd, "Otp is: " + digit); ds.choasSms(); Session["PotherDateTimeNow"] = otherDate; Label2.Text = "Message sent"; } else { Label2.Text = "Please wait one Minute before requesting"; } } }