public int Login(string username, string password, byte[] hwid) { try { if (Array.Exists(File.ReadAllLines("BannedHWIDs.txt"), x => x == Encoding.UTF8.GetString(hwid))) { return(clsResults.BANNED); } if (isLoggedIn) { if (isExpired) { return(clsResults.SUCCESS_EXPIRED); } else { return(clsResults.SUCCESS); } } if (!File.Exists(string.Format("Clients\\{0}.xml", username))) { return(clsResults.INVALID_USERNAME); } clsClient client = frmMain.ReadXML <clsClient>(string.Format("Clients\\{0}.xml", username)); if (!SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(password)).SequenceEqual(client.bPassword)) { return(clsResults.INVALID_PASSWORD); } if (!hwid.SequenceEqual(client.bHWID)) { return(clsResults.HWID_MISMATCH); } isLoggedIn = true; thisClient = client; foreach (clsUsedKey uKey in client.lHistory) { if (DateTime.Now.CompareTo(uKey.dtActivation.Add(new TimeSpan(uKey.iValidFor, 0, 0, 0))) <= 0) { isExpired = false; thisKey = uKey; UpdateInfo(); return(clsResults.SUCCESS); } } isExpired = true; UpdateInfo(); return(clsResults.SUCCESS_EXPIRED); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); return(clsResults.UNKNOWN_ERROR); } }