using Microsoft.Owin.Security.DataHandler.Encoder;
using System.Security.Cryptography;
public static void Main()
var base64Secret = CreateBase64Secret(size);
Console.WriteLine(base64Secret);
private static string CreateBase64Secret(int size)
var key = new byte[size];
RNGCryptoServiceProvider.Create().GetBytes(key);
var secret = TextEncodings.Base64Url.Encode(key);
private static string CreateBase64SecretWithNoDependencies(int size)
var key = new byte[size];
RandomNumberGenerator.Create().GetBytes(key);
var secret = Convert.ToBase64String(key);