git.fiddlerwoaroof.com
Browse code

feat(password-gen): add more conf options

fiddlerwoaroof authored on 27/01/2022 23:54:07
Showing 1 changed files
... ...
@@ -39,14 +39,15 @@
39 39
   (elt seq
40 40
        (random (length seq))))
41 41
 
42
-(defun generate-password (len human-readable exclude-excluded)
42
+(defun generate-password (len human-readable exclude-excluded additional-special asp)
43 43
   (let* ((upper (make-readable human-readable *uppercase*))
44 44
          (lower (make-readable human-readable *lowercase*))
45 45
          (number (make-readable human-readable *numbers*))
46 46
          (special-initial (make-readable human-readable *special-characters*))
47
-         (special (if exclude-excluded
48
-                      (set-difference special-initial *excluded-characters*)
49
-                      special-initial))
47
+         (special (cond (asp (coerce additional-special 'list))
48
+                        (exclude-excluded
49
+                         (set-difference special-initial *excluded-characters*))
50
+                        (t special-initial)))
50 51
          (character-groups (list upper lower number special))
51 52
          (initial-password (reduce (lambda (acc x)
52 53
                                      (cons (sample x) acc))
... ...
@@ -64,11 +65,11 @@
64 65
                      :initial-value initial-password))
65 66
             'string)))
66 67
 
67
-(defun main (len count &optional human-readable exclude-excluded)
68
+(defun main (len count &optional human-readable exclude-excluded (additional-special nil asp))
68 69
   (if (< len 4)
69 70
       (print "Length must be at least 4~%")
70 71
       (loop for x from 1 to count do
71
-        (princ (generate-password len human-readable exclude-excluded))
72
+        (princ (generate-password len human-readable exclude-excluded additional-special asp))
72 73
         (terpri))))
73 74
 
74 75
 (defun parse-bool (str)