mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
20 lines
546 B
C#
20 lines
546 B
C#
using System.Security.Cryptography;
|
|
|
|
namespace Remotely.Shared.Helpers;
|
|
|
|
public class RandomGenerator
|
|
{
|
|
private const string AllowableCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789";
|
|
|
|
public static string GenerateString(int length)
|
|
{
|
|
var bytes = RandomNumberGenerator.GetBytes(length);
|
|
return new string(bytes.Select(x => AllowableCharacters[x % AllowableCharacters.Length]).ToArray());
|
|
}
|
|
|
|
public static string GenerateAccessKey()
|
|
{
|
|
return GenerateString(64);
|
|
}
|
|
}
|