/
passwords-docs.factor
48 lines (42 loc) · 1.71 KB
/
passwords-docs.factor
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
! Copyright (C) 2019 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license.
USING: help.markup help.syntax kernel random strings ;
IN: random.passwords
ABOUT: "random.passwords"
ARTICLE: "random.passwords" "Generating random passwords"
"The " { $vocab-link "random.passwords" } " vocab provides functions for generation of random passwords."
$nl
"Generate password of a given length from some often used character sets:"
{ $subsections alnum-password hex-password ascii-password }
"Generate a password from a custom character set:"
{ $subsections password }
;
HELP: password
{ $values
{ "n" "password length" }
{ "charset" string }
{ "string" string }
}
{ $description "Generate a password of length " { $snippet "n" } " by randomly selecting characters from the " { $snippet "charset" } " string. All characters of the " { $snippet "charset" } " have equal probability of appearing at any position of the result."
$nl
"If " { $snippet "n" } " = 0, return empty string. If " { $snippet "n" } " < 0, throw an error."
$nl
{ $link secure-random-generator } " is used as the randomness source." } ;
HELP: alnum-password
{ $values
{ "n" "password length" }
{ "string" string }
}
{ $description "Generate a random password consisting of " { $snippet "n" } " alphanumeric characters (0..9, A..Z, a..z)." } ;
HELP: ascii-password
{ $values
{ "n" "password length" }
{ "string" string }
}
{ $description "Generate a random password consisting of " { $snippet "n" } " printable ASCII characters." } ;
HELP: hex-password
{ $values
{ "n" "password length" }
{ "string" string }
}
{ $description "Generate a random password consisting of " { $snippet "n" } " hexadecimal characters (0..9, A..F)." } ;