aboutsummaryrefslogtreecommitdiff
path: root/src/Web/ZeroBin/Utils.hs
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-11-04 11:10:01 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-11-04 11:17:05 +0300
commitab5802ad6d172adea49fc42edab9742551490be7 (patch)
tree9febbdec60779c5deb763d8ea023b55fed1abe76 /src/Web/ZeroBin/Utils.hs
parent5260b4b5d52cd7d7052c0fa980c048d857e2d14b (diff)
downloadzerobin-ab5802ad6d172adea49fc42edab9742551490be7.tar.gz
Use top-level name Web1.2.0
Diffstat (limited to 'src/Web/ZeroBin/Utils.hs')
-rw-r--r--src/Web/ZeroBin/Utils.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Web/ZeroBin/Utils.hs b/src/Web/ZeroBin/Utils.hs
new file mode 100644
index 0000000..915d8ad
--- /dev/null
+++ b/src/Web/ZeroBin/Utils.hs
@@ -0,0 +1,19 @@
+module Web.ZeroBin.Utils (
+ toWeb
+, makePassword
+) where
+
+import Crypto.Random.Entropy (getEntropy)
+import Data.ByteString (ByteString)
+import Data.ByteString.Base64 (encode)
+import Data.ByteString.Char8 (unpack)
+import Data.Char (isAlphaNum)
+
+
+toWeb :: ByteString -> String
+toWeb = takeWhile (/= '=') . unpack . encode
+
+makePassword :: Int -> IO String
+makePassword n = (map (\c -> if isAlphaNum c then c else 'X')
+ . toWeb) `fmap` getEntropy n
+