mirror of
https://github.com/Jetsparrow/jetherald.git
synced 2026-01-21 07:56:09 +03:00
22 lines
542 B
C#
22 lines
542 B
C#
using System;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace JetHerald
|
|
{
|
|
public static class TokenHelper
|
|
{
|
|
static RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
|
|
static byte[] buf = new byte[24];
|
|
static readonly object SyncLock = new object();
|
|
|
|
public static string GetToken()
|
|
{
|
|
lock (SyncLock)
|
|
{
|
|
rng.GetBytes(buf);
|
|
return Convert.ToBase64String(buf).Replace('+', '_').Replace('/', '_');
|
|
}
|
|
}
|
|
}
|
|
}
|