internal async Task <bool> KeyGen_Verify(string Key) //, int DirCustomersID { string sKey = Key, sKey2 = Key; //Расскодируем "AES" PartionnyAccount.Classes.Crypto.AES aES = new Classes.Crypto.AES(); Key = sKey = aES.DecryptStringAES(sKey, aES.password); // === === === === === === === === === === === === === === === === === === === //1. Получаем 2-а "DirCustomersID" //2. Проверяем равны ли они (нет - исключение: Key не правильный, у Вас осталось 7 попыток.) //3. Ищем в БД (MS SQL) "DirCustomersID" и получаем pUsers (Login) (не находим - исключение: Key не правильный, у Вас осталось 7 попыток.) //4. Проверяем в БД (SQLite) клиента Key // - Совпадает - получаем дополнительные // - не совпадает - исключение: Key не правильный, у Вас осталось 7 попыток. //Создаём копию "Key" //string sKey = Key; #region 1. Получаем 2-а "DirCustomersID" #region 1.1. Получаем X1 - сдвиг от 1 - 10 === === === string sX1 = Key[0].ToString(); int X1; bool bX1 = Int32.TryParse(sX1, out X1); if (!bX1) { throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); } #endregion #region 1.3. Получаем Y1 - К-во символов в "DirCustomersID-1" === === === Key = Key.Remove(0, 9); string sY1 = Key[0].ToString(); int Y1; bool bY1 = Int32.TryParse(sY1, out Y1); if (!bY1) { throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); } //Удаляем Y1 Key = Key.Remove(0, 1); //Считываем Y1 символов - это и будет первый "DirCustomersID" string sDirCustomersID1 = ""; for (int i = 0; i < Y1; i++) { sDirCustomersID1 += Key[i].ToString(); } /* * int DirCustomersID1; * bool bDirCustomersID1 = Int32.TryParse(sDirCustomersID1, out DirCustomersID1); * if (!bDirCustomersID1) throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); */ #endregion #region 1.3. Получаем 2-й "DirCustomersID" Key = Key.Remove(0, Y1 + 12); /* * Y1 - уже нашли * string sY1 = Key[0].ToString(); * * int Y1; * bool bY1 = Int32.TryParse(sY1, out Y1); * if (!bY1) throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); */ //Удаляем Y1 //Key = Key.Remove(0, 1); //Считываем Y1 символов - это и будет первый "DirCustomersID" string sDirCustomersID2 = ""; for (int i = 0; i < Y1; i++) { sDirCustomersID2 += Key[i].ToString(); } /* * int DirCustomersID2; * bool bDirCustomersID2 = Int32.TryParse(sDirCustomersID2, out DirCustomersID2); * if (!bDirCustomersID2) throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); */ #endregion #endregion #region 2. Проверяем равны ли они (нет - исключение: Key не правильный, у Вас осталось 7 попыток.) if (sDirCustomersID1 != sDirCustomersID2) { throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); } #endregion #region Декодируем "DirCustomersID" //Колируем "DirCustomersID" PartionnyAccount.Classes.Function.RandomSymbol randomSymbol2 = new PartionnyAccount.Classes.Function.RandomSymbol(); //int iDirCustomersID = 0; try { iDirCustomersID = Convert.ToInt32(randomSymbol2.ReturnInteger_Decode(sDirCustomersID1, X1)); } catch { throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); } #endregion #region 3. Ищем в БД (MS SQL) "DirCustomersID" и получаем pUsers (Login) (не находим - исключение: Key не правильный, у Вас осталось 7 попыток.) string pUsersID = connectionString.mDLogin(iDirCustomersID); // _var.VerifyUser_MSSQL_Login(iDirCustomersID); //Не нашло или клиент не активный if (String.IsNullOrEmpty(pUsersID)) { throw new System.InvalidOperationException(PartionnyAccount.Classes.Language.Sklad.Language.msg93); } #endregion #region 4. Проверяем в БД (SQLite) клиента Key db = new DbConnectionSklad(connectionString.Return(iDirCustomersID, null, true)); var query = await Task.Run(() => ( from x in db.API10s where x.API10Key == sKey2 select x ).ToListAsync()); if (query.Count() > 0) { if (query[0].API10Key == sKey2) { return(true); } else { return(false); } } else { return(false); } #endregion }