1<?php
2
3/**
4 * This does nothing if the libsodium extension is loaded, so it's harmless.
5 *
6 * This file alone is released under CC0 and WTFPL dual licensing.
7 */
8namespace Sodium {
9    if (!extension_loaded('libsodium')) {
10
11        /**
12         * Generate a string of random bytes
13         * /dev/urandom
14         *
15         * @param int $length
16         * @return string
17         */
18        function randombytes_buf(
19            $length
20        )
21        {
22            return '';
23        }
24
25        /**
26         * Generate a 16-bit integer
27         * /dev/urandom
28         *
29         * @return int
30         */
31        function randombytes_random16()
32        {
33            return '';
34        }
35
36        /**
37         * Generate an unbiased random integer between 0 and a specified value
38         * /dev/urandom
39         *
40         * @param int $upperBoundNonInclusive
41         * @return int
42         */
43        function randombytes_uniform(
44            $upperBoundNonInclusive
45        )
46        {
47            return 0;
48        }
49    }
50}
51namespace {
52    class Sodium
53    {
54
55        /**
56         * Generate a string of random bytes
57         * /dev/urandom
58         *
59         * @param int $length
60         * @return string
61         */
62        public static function randombytes_buf($length)
63        {
64            return '';
65        }
66
67        /**
68         * Generate a 16-bit integer
69         * /dev/urandom
70         *
71         * @return int
72         */
73        public static function randombytes_random16()
74        {
75            return '';
76        }
77
78        /**
79         * Generate an unbiased random integer between 0 and a specified value
80         * /dev/urandom
81         *
82         * @param int $upperBoundNonInclusive
83         * @return int
84         */
85        public static function randombytes_uniform($upperBoundNonInclusive = 0)
86        {
87            return 0;
88        }
89    }
90}