/// <summary> /// This Method confirms whether the old hash code and newly genrated hash code are same or not. /// </summary> /// <param name="oldHash">It is old hash code of the user</param> /// <returns>Returns true if hash codes are same else returns false.</returns> public bool VerifyUser(string oldHash) { DbManager dbManager = new DbManager(); DataTable dtUserInformation = dbManager.GetUserInformation(_userID); if (dtUserInformation != null) { string hashingData1 = dtUserInformation.Rows[0]["deviceVenderID"].ToString() + dtUserInformation.Rows[0]["applicationID"].ToString() + _userID; string hashingData2 = _userID + dtUserInformation.Rows[0]["deviceVenderID"].ToString() + dtUserInformation.Rows[0]["applicationID"].ToString(); string newHash1 = NeeoUtility.GenerateMd5Hash(hashingData1); string newHash2 = NeeoUtility.GenerateMd5Hash(hashingData2); if (newHash1 == oldHash || newHash2 == oldHash) { return(true); } else { return(false); } } else { return(false); } #region Commentted implementation // string hashingData; // DbManager dbManager = new DbManager(); // DataTable dtUserInformation = dbManager.GetUserInformation(_userID); // if (dtUserInformation != null) // { // if (dtUserInformation.Rows[0]["appVersion"].ToString() == "NEEO-3.0.1") // { // hashingData = _userID + dtUserInformation.Rows[0] //["deviceVenderID"].ToString() + // dtUserInformation.Rows[0]["applicationID"].ToString(); // } // else // { // hashingData = dtUserInformation.Rows[0]["deviceVenderID"].ToString() + // dtUserInformation.Rows[0]["applicationID"].ToString //() + _userID; // } // if (hashingData != null) // { // string newHash = NeeoUtility.GenerateMd5Hash(hashingData); // if (newHash == oldHash) // { // return true; // } // else // { // return false; // } // } // else // { // return false; // } // } // else // { // return false; // } #endregion }
/// <summary> /// Generates MD5 encrypted device key based on phone number and device vender id. /// </summary> /// <param name="phoneNumber">A string containing the phone number.</param> /// <param name="deviceVenderID">A string containing the device specific venderID.</param> /// <returns>A hexadecimal string generated from MD5 encryption.</returns> private static string GenerateDeviceKey(string phoneNumber, string deviceVenderID, string applicationID) { string hashingData = phoneNumber + deviceVenderID + applicationID; return(NeeoUtility.GenerateMd5Hash(hashingData)); }