aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Giovanini <gabrielg.desouza@gmail.com>2019-06-22 15:40:06 +0200
committerGabriel Giovanini <gabrielg.desouza@gmail.com>2019-06-22 15:40:06 +0200
commitddce2bd3c66a62cb96b2b7ef0602c00c586c429b (patch)
treeb5cd3261c2a65fbd131d78b2ecce2f9100a21104 /src
downloadgenpass-ddce2bd3c66a62cb96b2b7ef0602c00c586c429b.tar.gz
genpass-ddce2bd3c66a62cb96b2b7ef0602c00c586c429b.tar.bz2
genpass-ddce2bd3c66a62cb96b2b7ef0602c00c586c429b.zip
Bootstrap web site
Diffstat (limited to 'src')
-rw-r--r--src/genpass/core.cljs18
-rw-r--r--src/genpass/gen.cljc20
2 files changed, 38 insertions, 0 deletions
diff --git a/src/genpass/core.cljs b/src/genpass/core.cljs
new file mode 100644
index 0000000..e6b33ca
--- /dev/null
+++ b/src/genpass/core.cljs
@@ -0,0 +1,18 @@
+(ns genpass.core
+ (:require
+ [reagent.core :as r]))
+
+;; -------------------------
+;; Views
+
+(defn home-page []
+ [:div [:h2 "Welcome to Reagent"]])
+
+;; -------------------------
+;; Initialize app
+
+(defn mount-root []
+ (r/render [home-page] (.getElementById js/document "app")))
+
+(defn init! []
+ (mount-root))
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