1: <?php
2: namespace Hyperwallet\Util;
3:
4: use Hyperwallet\Exception\HyperwalletException;
5:
6: /**
7: * The encryption service for Hyperwallet client's requests/responses
8: *
9: * @package Hyperwallet\Util
10: */
11: class HyperwalletUUID {
12:
13: /**
14: * Generates UUID
15: *
16: * @return string
17: *
18: * @throws HyperwalletException
19: */
20: public static function v4() {
21: return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
22:
23: // 32 bits for "time_low"
24: mt_rand(0, 0xffff), mt_rand(0, 0xffff),
25:
26: // 16 bits for "time_mid"
27: mt_rand(0, 0xffff),
28:
29: // 16 bits for "time_hi_and_version",
30: // four most significant bits holds version number 4
31: mt_rand(0, 0x0fff) | 0x4000,
32:
33: // 16 bits, 8 bits for "clk_seq_hi_res",
34: // 8 bits for "clk_seq_low",
35: // two most significant bits holds zero and one for variant DCE1.1
36: mt_rand(0, 0x3fff) | 0x8000,
37:
38: // 48 bits for "node"
39: mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
40: );
41: }
42: }
43: