private void UpdateDefaultOauthParameters() { OauthParameters["nonce"] = RngHelper.GetRandomHexString(10); OauthParameters["timestamp"] = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); OauthParameters["consumer_key"] = _consumerKey; OauthParameters["signature_method"] = SignatureMethod; OauthParameters["version"] = Version; }
public static void Shuffle <T>(this IList <T> list) { int listCount = list.Count; while (listCount > 1) { listCount--; int randomIndex = RngHelper.GetRandom(0, listCount + 1); T value = list[randomIndex]; list[randomIndex] = list[listCount]; list[listCount] = value; } }
public async Task <UserAccessToken> CreateUserAccessTokenAsync(int userId, CreateAccessTokenRequest request) { using (var uow = _unitOfWorkFactory.CreateUnitOfWork()) { var token = new UserAccessToken { Id = Guid.NewGuid(), Key = RngHelper.GetRandomHexString(64), Name = request.Name, UserId = userId, DateCreated = _timeService.UtcNow }; uow.UserAccessTokenRepository.Add(token); await uow.SaveChangesAsync(); return(token); } }
public int GetRandomInt(int min, int max) { return(RngHelper.GetRandomInt(min, max)); }
public int GetRandomInt() { return(RngHelper.GetRandomInt()); }
public string GetRandomString(string prefix) { return(RngHelper.GetRandomString(prefix)); }
public string GetRandomHexString(int byteCount) { return(RngHelper.GetRandomHexString(byteCount)); }