summaryrefslogtreecommitdiff
path: root/README
blob: d470444d74e0700ab577df3dbac9b046f3550eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
rg - random string generator
============================
rg prints cryptographically random alphanumeric strings. It is a
suckless rewrite of rg.veltar.systems as a small C program that
builds on Linux and Windows.

	rg [-v] [-n n] [-l l]

n	number of strings (default 6, min 1, max 1000)
l	length of each string (default 10, min 1, max 256)


Requirements
------------
A C99 compiler.

Linux:  libc with getrandom(2) (glibc 2.25+).
Windows: a compiler with rand_s (MSVC, clang targeting MSVC, or
MinGW-w64).


Installation
------------
Edit config.mk to match your local setup. Edit config.def.h for the
alphabet and limits.

Linux:

	make clean install

Windows (GNU make + clang, from this tree):

	make

The Windows bits of config.mk are selected when OS=Windows_NT.
Otherwise set CC, EXE=.exe, and CPPFLAGS by hand as commented there.


Running without make
--------------------
	cp config.def.h config.h

Linux:

	cc -std=c99 -D_DEFAULT_SOURCE -o rg rg.c

Windows (clang / MSVC CRT):

	clang -std=c99 -D_CRT_RAND_S -o rg.exe rg.c

Windows (MinGW-w64):

	gcc -std=c99 -D_CRT_RAND_S -o rg.exe rg.c


Usage
-----
	rg
	rg -n 6 -l 10
	rg -n 1 -l 32


Configuration
-------------
Copy config.def.h to config.h (make does this) and edit. Do not
edit rg.c for configuration.


Remarks
-------
The original page at rg.veltar.systems used n % alphabet.length on
raw 32-bit draws, which is slightly biased. This program rejects
values in the incomplete last bucket so each symbol is equiprobable.