1 ! Copyright (C) 2019 Alexander Ilin.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: fry literals math.ranges random sequences ;
8 CONSTANT: ascii-printable-charset $[ 33 126 [a..b] ]
9 CONSTANT: hex-charset "0123456789ABCDEF"
10 CONSTANT: alphanum-charset $[
11 CHAR: 0 CHAR: 9 [a..b]
12 CHAR: a CHAR: z [a..b] append
13 CHAR: A CHAR: Z [a..b] append ]
17 : password ( n charset -- string )
18 '[ [ _ random ] "" replicate-as ] with-secure-random ;
20 : ascii-password ( n -- string )
21 ascii-printable-charset password ;
23 : hex-password ( n -- string )
24 hex-charset password ;
26 : alnum-password ( n -- string )
27 alphanum-charset password ;