aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel <desouza@oculavis.de>2019-08-07 16:15:30 -0300
committerGabriel <desouza@oculavis.de>2019-08-07 16:15:30 -0300
commitbead8526d9229cba103115c136a37856cd971752 (patch)
treefa7c268e8bcad15b614be49203bba6b17f5561b3 /src
parent879622495be02fa38fc1f9b8ca7c900e33d79fe6 (diff)
downloadgenpass-bead8526d9229cba103115c136a37856cd971752.tar.gz
genpass-bead8526d9229cba103115c136a37856cd971752.tar.bz2
genpass-bead8526d9229cba103115c136a37856cd971752.zip
Make genpwd simpler
Diffstat (limited to 'src')
-rw-r--r--src/genpass/gen.cljc11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/genpass/gen.cljc b/src/genpass/gen.cljc
index 103734d..12dbc2f 100644
--- a/src/genpass/gen.cljc
+++ b/src/genpass/gen.cljc
@@ -4,7 +4,7 @@
(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)))
+(def all-char (concat low-case upper-case number special-char))
(defn rand-char []
(nth all-char (rand-int (dec (count all-char)))))
@@ -12,9 +12,6 @@
(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
+ (->> (range length)
+ (map (fn [_] (rand-char)))
+ (apply str)))) \ No newline at end of file