mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
26 lines
661 B
C#
26 lines
661 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Linq;
|
|
|
|
namespace Remotely_Library.Services
|
|
{
|
|
public class RandomGenerator
|
|
{
|
|
private const string allowableCharacters = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
|
|
public string GenerateString(int length)
|
|
{
|
|
var bytes = new byte[length];
|
|
|
|
using (var random = RandomNumberGenerator.Create())
|
|
{
|
|
random.GetBytes(bytes);
|
|
}
|
|
|
|
return new string(bytes.Select(x => allowableCharacters[x % allowableCharacters.Length]).ToArray());
|
|
}
|
|
}
|
|
}
|