EN
C#/.NET - generate random bytes
2 points
xxxxxxxxxx
1
public static class RandomUtils
2
{
3
public static string generateBytes(int count)
4
{
5
Random random = new Random();
6
byte[] result = new byte[count];
7
8
random.NextBytes(result);
9
10
return result;
11
}
12
}
Example:
xxxxxxxxxx
1
string bytes = RandomUtils.generateBytes(6);
2
3
foreach(byte entry in bytes)
4
Console.Write(entry + " ");
5
6
Console.WriteLine();
Output:
xxxxxxxxxx
1
34 4 1 197 85 145