summaryrefslogtreecommitdiff
path: root/VPNAuth.Server/PkceUtils.cs
diff options
context:
space:
mode:
authorTim <contact@bytim.eu>2025-04-18 12:25:59 +0200
committerTim <contact@bytim.eu>2025-04-18 12:25:59 +0200
commit4b2ad030fa381662f4b0c2464e97b0d2c5f6a716 (patch)
treedcc6af3136764322bd779110dcedd35e293d583c /VPNAuth.Server/PkceUtils.cs
downloadVPNAuth-4b2ad030fa381662f4b0c2464e97b0d2c5f6a716.tar.xz
VPNAuth-4b2ad030fa381662f4b0c2464e97b0d2c5f6a716.zip
Initial commit
Diffstat (limited to 'VPNAuth.Server/PkceUtils.cs')
-rw-r--r--VPNAuth.Server/PkceUtils.cs17
1 files changed, 17 insertions, 0 deletions
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
+}