diff options
Diffstat (limited to 'src/genpass/gen.cljc')
-rw-r--r-- | src/genpass/gen.cljc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/genpass/gen.cljc b/src/genpass/gen.cljc new file mode 100644 index 0000000..103734d --- /dev/null +++ b/src/genpass/gen.cljc @@ -0,0 +1,20 @@ +(ns genpass.gen) + +(def low-case [\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]) +(def upper-case [\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]) +(def number [\0 \1 \2 \3 \4 \5 \6 \7 \8 \9]) +(def special-char [\! \@ \# \% \^ \& \* \( \) \{ \} \[ \] \- \+ \= \~]) +(def all-char (into [] (concat low-case upper-case number special-char))) + +(defn rand-char [] + (nth all-char (rand-int (dec (count all-char))))) + +(defn genpwd + ([] (genpwd 12)) + ([length] + (genpwd length "")) + ([length pwd] + (if (>= 0 length) + pwd + (recur (dec length) + (str pwd (rand-char))))))
\ No newline at end of file |