From 4b2ad030fa381662f4b0c2464e97b0d2c5f6a716 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 18 Apr 2025 12:25:59 +0200 Subject: Initial commit --- VPNAuth.Server/PkceUtils.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 VPNAuth.Server/PkceUtils.cs (limited to 'VPNAuth.Server/PkceUtils.cs') diff --git a/VPNAuth.Server/PkceUtils.cs b/VPNAuth.Server/PkceUtils.cs new file mode 100644 index 0000000..a11926e --- /dev/null +++ b/VPNAuth.Server/PkceUtils.cs @@ -0,0 +1,17 @@ +namespace VPNAuth.Server; + +public static class PkceUtils +{ + private static string _codeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; + + public static string GenerateCode(int length = 10) + { + string code = ""; + for (int i = 0; i < length; i++) + code += _codeChars[new Random().Next(_codeChars.Length)]; // TODO: Is that function random enough? + return code; + } + + public static string GenerateToken(int length = 20) + => GenerateCode(length); // TODO: maybe add more possible chars then for GenerateCode +} -- cgit v1.2.3