From 22c9c53b1db8b4ff6d49e5fa0406a96773c14d50 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 12 Mar 2017 22:23:25 +0100 Subject: Drop libuuid dependency, uuid generation is not that complicated... --- xmpp-vala/src/module/util.vala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'xmpp-vala/src') 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 : Object { -- cgit v1.2.3-70-g09d2