Created
October 7, 2021 12:21
-
-
Save ArtemAvramenko/c7a979661df5e0157cc64d0703d75415 to your computer and use it in GitHub Desktop.
Get unique array of letters in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string GetUniqueStringValue(int size) | |
{ | |
var data = new byte[size]; | |
using var crypto = RandomNumberGenerator.Create(); | |
crypto.GetBytes(data); | |
for (var i = 0; i < size; i++) | |
{ | |
data[i] = (byte)('a' + data[i] % 26); | |
} | |
return Encoding.ASCII.GetString(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment