summaryrefslogtreecommitdiff
path: root/src/marlin.core/util/SecureTokenGenerator.cs
blob: f99918cfc6d72b9e24a2bde6e4ee7dd229f6b22c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
namespace marlin.core.util;

using System.Security.Cryptography;

public class SecureTokenGenerator
{
    private const string ALLOWED_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    private static string Create(int length = 32)
    {
        return RandomNumberGenerator.GetString(ALLOWED_CHARS, length);
    }

    public static string CreateAgentToken() => "ag-" + Create();
    public static string CreateClaimToken() => "cl-" + Create();
}