From e06d23ff2d49d94aca1c99f553c9c3ae4a20c289 Mon Sep 17 00:00:00 2001 From: rearman Date: Thu, 18 Sep 2025 11:58:37 -0400 Subject: [PATCH] Condense the lists of characters into two Only care about the split between special/non-special, so combine non-special characters into one list, called alphanumerics. --- re/re-pass-alike.el | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/re/re-pass-alike.el b/re/re-pass-alike.el index 734baee..01ba9bd 100644 --- a/re/re-pass-alike.el +++ b/re/re-pass-alike.el @@ -106,31 +106,24 @@ Assumes same structure as `pass(1)'." ;; Password generation -(defconst *lowercase* +(defconst *alphanumerics* '("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" - "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z") - "List of strings containing the lowercase English alphabet.") - -(defconst *uppercase* - '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" - "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z") - "List of strings containing the uppercase English alphabet.") - -(defconst *numbers* - '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9") - "List of strings containing the single-digit numbers.") - -(defconst *special-characters* '("!" "?" "$" "%" "&" "'" "(" ")" "*" - "+" "," "-" "." "/" ":" ";" "<" "=" ">" - "?" "@" "[" "]" "^" "_" "{" "|" "}" "~") + "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" + "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" + "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" + "0" "1" "2" "3" "4" "5" "6" "7" "8" "9") + "List of strings of the upper/lower-case English alphabet, and the single-digit numbers.") + +(defconst *special-characters* + '("!" "?" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." + "/" ":" ";" "<" "=" ">" "?" "@" "[" "]" "^" "_" "{" + "|" "}" "~") "List of strings containing the special visible characters excluding \\ and \" .") (defun pw-get-char (&optional no-special-chars) "Select a single character at random to be used in a password. If `no-special-chars' is t, use only alpha-numeric characters." - (let ((selected-charset (append *lowercase* - *uppercase* - *numbers* + (let ((selected-charset (append *alphanumerics* (when (null no-special-chars) *special-characters*)))) (elt selected-charset (random (length selected-charset))))) -- 2.39.5