blob: 915d8ad4baeb03b8befe7432746ec5ab812a8471 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
|