![]() ![]() Var key = KeyGenerator. Select(e => new %") įoreach (var ch in KeyGenerator.chars) counts.Add(ch, 0) Var totalCountsThisRun = experiments.SelectMany(e => e.Result) Var experiments = Enumerable.Range(0, TASK_COUNT).Select(i => Task.Run(Experiment)).ToArray() I heard LINQ is the new black, so heres my attempt using LINQ: private static Random random new Random() public static string RandomString(int length). StringBuilder result = new StringBuilder(size) įoreach (var ch in ) counts.Add(ch, 0) įoreach (var ch in KeyGenerator.chars) grandTotalCounts.Add(ch, 0) Using (var crypto = RandomNumberGenerator.Create()) ![]() Public static string GetUniqueKey(int size) I want to generate a different random string every time I use the function. ![]() "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray() Unlike some of the alternatives presented, this one is cryptographically sound. Input the length of string and get multiple random strings in. NET Standard 2.1 or above) provides a cryptographically sound method RandomNumberGenerator.GetInt32() to generate a random integer within a desired range. Use our random string generator to create random strings of any length and character set. NET Core 3 (and future platforms that support. The update generates all characters ~1.61% of the time.įRAMEWORK SUPPORT. The original implementation generated a-h ~1.95% of the time and the remaining characters ~1.56% of the time. The code in the answer has been updated accordingly. Instead, call RandomNumberGenerator.Create(). RNGCryptoServiceProvider is marked as obsolete. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |