aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-12 22:23:25 +0100
committerMarvin W <git@larma.de>2017-03-12 22:23:25 +0100
commit22c9c53b1db8b4ff6d49e5fa0406a96773c14d50 (patch)
tree319b5e32c0edaee29cde0be2228b97599262c1a4 /xmpp-vala/src/module
parentbd1f116b3a57b803e2be4dc92474937f1f824fe4 (diff)
downloaddino-22c9c53b1db8b4ff6d49e5fa0406a96773c14d50.tar.gz
dino-22c9c53b1db8b4ff6d49e5fa0406a96773c14d50.zip
Drop libuuid dependency, uuid generation is not that complicated...
Diffstat (limited to 'xmpp-vala/src/module')
-rw-r--r--xmpp-vala/src/module/util.vala12
1 files changed, 7 insertions, 5 deletions
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala
index 7e1bb2b3..9096ea32 100644
--- a/xmpp-vala/src/module/util.vala
+++ b/xmpp-vala/src/module/util.vala
@@ -12,11 +12,13 @@ namespace Xmpp {
}
public string random_uuid() {
- uint8[] rand = new uint8[16];
- char[] str = new char[37];
- UUID.generate_random(rand);
- UUID.unparse_upper(rand, str);
- return (string) str;
+ uint32 b1 = Random.next_int();
+ uint16 b2 = (uint16)Random.next_int();
+ uint16 b3 = (uint16)(Random.next_int() | 0x4000u) & ~0xb000u;
+ uint16 b4 = (uint16)(Random.next_int() | 0x8000u) & ~0x4000u;
+ uint16 b5_1 = (uint16)Random.next_int();
+ uint32 b5_2 = Random.next_int();
+ return "%08x-%04x-%04x-%04x-%04x%08x".printf(b1, b2, b3, b4, b5_1, b5_2);
}
public class Tuple<A,B> : Object {