summaryrefslogtreecommitdiff
path: root/src/Support/Id.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Support/Id.php')
-rw-r--r--src/Support/Id.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Support/Id.php b/src/Support/Id.php
new file mode 100644
index 0000000..dc23631
--- /dev/null
+++ b/src/Support/Id.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Support;
+
+class Id
+{
+ public static function generate(string $prefix = "", string $suffix = "", string $salt = ""): string
+ {
+ return $prefix . md5(time() . random_bytes(512)) . $suffix;
+ }
+
+ public static function generateRoomId(): string
+ {
+ return self::generate(prefix: "!", suffix: ":" . $_ENV["DOMAIN"]);
+ }
+
+ public static function generateEventId(): string
+ {
+ return self::generate(prefix: "$", suffix: ":" . $_ENV["DOMAIN"]);
+ }
+}