/// <summary> /// Initializes the <see cref="PokeHashHasher"/>. /// </summary> /// <param name="authKeys">The PokeHash authkeys obtained from https://talk.pogodev.org/d/51-api-hashing-service-by-pokefarmer. </param> public PokeHashHasher(string[] authKeys) { if (authKeys.Length == 0) { throw new ArgumentException($"{nameof(authKeys)} may not be empty."); } _authKeys = new List <PokeHashAuthKey>(); // We don't want any duplicate keys. foreach (var authKey in authKeys) { var pokeHashAuthKey = new PokeHashAuthKey(authKey); if (_authKeys.Contains(pokeHashAuthKey)) { throw new Exception($"The auth key '{authKey}' is a duplicate."); } _authKeys.Add(pokeHashAuthKey); } // Initialize HttpClient. _httpClient = new HttpClient { BaseAddress = new Uri(PokeHashUrl) }; _httpClient.DefaultRequestHeaders.Clear(); _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd("POGOLib (https://github.com/AeonLucid/POGOLib)"); _keySelection = new Semaphore(1, 1); }
/// <summary> /// Initializes the <see cref="PokeHashHasher"/>. /// </summary> /// <param name="authKeys">The PokeHash authkeys obtained from https://talk.pogodev.org/d/51-api-hashing-service-by-pokefarmer. </param> public PokeHashHasher(string[] authKeys) { if (authKeys.Length < 1) { throw new PokeHashException($"{nameof(authKeys)} may not be empty."); } _authKeys = new List <PokeHashAuthKey>(); // We don't want any duplicate keys. foreach (var authKey in authKeys) { var pokeHashAuthKey = new PokeHashAuthKey(authKey); if (_authKeys.Contains(pokeHashAuthKey)) { throw new PokeHashException($"The auth key '{authKey}' is a duplicate."); } _authKeys.Add(pokeHashAuthKey); } var rnd = new Random(); _authHashers = _authHashers.OrderBy(item => rnd.Next()).ToList(); if (!Configuration.IgnoreHashSemafore) { _keySelection = new Semaphore(1, 1); } }
/// <summary> /// Initializes the <see cref="PokeHashHasher"/>. /// </summary> /// <param name="authKeys">The PokeHash authkeys obtained from https://talk.pogodev.org/d/51-api-hashing-service-by-pokefarmer. </param> public PokeHashHasher(string[] authKeys) { if (authKeys.Length < 1) { throw new PokeHashException($"{nameof(authKeys)} may not be empty."); } _authKeys = new List <PokeHashAuthKey>(); // We don't want any duplicate keys. foreach (var authKey in authKeys) { var pokeHashAuthKey = new PokeHashAuthKey(authKey); if (_authKeys.Contains(pokeHashAuthKey)) { throw new PokeHashException($"The auth key '{authKey}' is a duplicate."); } _authKeys.Add(pokeHashAuthKey); } _keySelection = new Semaphore(1, 1); }