diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-11-11 10:03:20 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-11-11 10:03:20 -0700 |
commit | 23203bf9cac8bc28f21ff6e1260463535d0b7672 (patch) | |
tree | 09dda1dfbf3db836d7257b3703ae9dc9c0fa404d /src/util.lisp | |
parent | 4aad65f5415e166310282dd713e3c750fce2c9f8 (diff) | |
download | consfigurator-23203bf9cac8bc28f21ff6e1260463535d0b7672.tar.gz |
add RANDOM-ALPHANUMERIC
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/util.lisp')
-rw-r--r-- | src/util.lisp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp index cee463f..0bbf585 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -373,6 +373,14 @@ expansion as a starting point for your own DEFPACKAGE form for your consfig." "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" :test #'string=) +(defun random-alphanumeric (length) + "Return a random alphanumeric string of length LENGTH." + (aprog1 (make-string length) + (loop with *random-state* = (make-random-state t) + for i below length + do (setf (char it i) + (char +alphanum+ (random #.(length +alphanum+))))))) + (defun mkfifo () "Use mkfifo(3) to create a named pipe with a mkstemp(3)-like name." (let* ((dir (drop-trailing-slash (or (getenv "TMPDIR") "/tmp"))) |