Docs / Random values

Random values

Randomness goes wrong in ways that tests do not reveal, because a flawed random value still looks random. The best-known flaw is modulo bias: taking a random number and reducing it with % makes some results slightly more likely than others whenever the range does not divide the generator's range evenly. For a dice roll the effect is invisible; for drawing a winner it is a measurable skew.

The generator matters as much as the arithmetic. General-purpose generators such as the Mersenne Twister are fast and statistically good, and their future output can be predicted from enough past output, so they are wrong for passwords, tokens and anything an adversary might try to guess. Every value in this group comes from the operating system's cryptographically secure generator, and integers in a range are drawn by rejection sampling, which has no bias.

A UUID of version 4 is random and unordered; version 7 begins with a timestamp, so it sorts by creation time and reveals roughly when it was made. Password strength is a property of the alphabet and the length, and each password answer states its entropy in bits.

The service's own limitations are stated as well. A random value produced here travels over the network to reach you, so it is suitable for tests, identifiers and one-off use, and a value that protects something important is better generated where it will be used. Answers are never cached, and generated values are not logged.

Every endpoint in this group

/random/uuid?[count=]

Random UUID version 4

count (optional): how many, 1-1000

curl "https://agent-helper.org/random/uuid"

/random/uuid/v7?[count=]

UUID version 7: sortable by creation time (Unix ms) plus 74 random bits

count (optional): how many, 1-1000

curl "https://agent-helper.org/random/uuid/v7"

/random/int?min=&max=&[count=]

Uniform random integers in an inclusive range (no modulo bias)

min: lowest value, inclusive; max: highest value, inclusive; count (optional): how many, 1-1000

curl "https://agent-helper.org/random/int?min=1&max=6"

/random/choice?items=&[count=]

Pick items from a list, with replacement

items: comma-separated items; count (optional): how many, 1-1000

curl "https://agent-helper.org/random/choice?items=red,green,blue"

/random/sample?items=&count=

Pick distinct items from a list, without replacement

items: comma-separated items; count: how many distinct items

curl "https://agent-helper.org/random/sample?items=a,b,c,d,e&count=2"

/random/shuffle?items=

Random permutation of a list

items: comma-separated items

curl "https://agent-helper.org/random/shuffle?items=1,2,3,4,5"

/random/password?[length=]&[symbols=]&[ambiguous=]&[count=]

Random password with stated entropy

length (optional): characters, 4-256; symbols (optional): include punctuation; ambiguous (optional): include look-alike characters Il1O0o; count (optional): how many, 1-1000

curl "https://agent-helper.org/random/password"

/random/passphrase?[words=]&[separator=]&[count=]

Diceware-style passphrase from the EFF large wordlist

words (optional): number of words, 3-20; separator (optional): separator; count (optional): how many, 1-1000

curl "https://agent-helper.org/random/passphrase"

/random/bytes?[n=]&[output=]

Random bytes as hex or base64

n (optional): number of bytes, 1-4096; output (optional): hex, base64 or base64url

curl "https://agent-helper.org/random/bytes"