From ab5802ad6d172adea49fc42edab9742551490be7 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Wed, 4 Nov 2015 11:10:01 +0300 Subject: Use top-level name Web --- src/Web/ZeroBin/Utils.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/Web/ZeroBin/Utils.hs (limited to 'src/Web/ZeroBin/Utils.hs') 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 + -- cgit v1.2.3