summaryrefslogtreecommitdiff
path: root/VPNAuth.Server/PkceUtils.cs
diff options
context:
space:
mode:
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
+}