2 .\" Copyright (C) 2023 Alejandro Colomar <alx@kernel.org>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .TH arc4random 3 (date) "Linux man-pages (unreleased)"
8 arc4random, arc4random_uniform, arc4random_buf
9 \- cryptographically-secure pseudorandom number generator
12 .RI ( libc ", " \-lc )
15 .B #include <stdlib.h>
17 .B uint32_t arc4random(void);
18 .BI "uint32_t arc4random_uniform(uint32_t " upper_bound );
19 .BI "void arc4random_buf(void " buf [. n "], size_t " n );
22 These functions give cryptographically-secure pseudorandom numbers.
25 returns a uniformly-distributed value.
27 .BR arc4random_uniform ()
28 returns a uniformly-distributed value less than
33 fills the memory pointed to by
37 bytes of pseudorandom data.
43 families of functions should only be used where
44 the quality of the pseudorandom numbers is not a concern
46 there's a need for repeatability of the results.
47 Unless you meet both of those conditions,
53 returns a pseudorandom number.
55 .BR arc4random_uniform ()
56 returns a pseudorandom number less than
64 For an explanation of the terms used in this section, see
70 Interface Attribute Value
75 .BR arc4random_uniform (),
77 T} Thread safety MT-Safe
93 doesn't make sense in a call to
94 .BR arc4random_uniform ().
95 Such a call will fail, and return
103 such as accessing an array,
104 using that value could result in Undefined Behavior.