wordpass 0.1.0.0 → 0.2.0.0
raw patch · 3 files changed
+25/−9 lines, 3 files
Files
- Data/Random/RVar/Enum.hs +12/−0
- WordPass.hs +8/−2
- wordpass.cabal +5/−7
+ Data/Random/RVar/Enum.hs view
@@ -0,0 +1,12 @@+{-# LANGUAGE OverlappingInstances, MultiParamTypeClasses, FlexibleInstances #-}+module Data.Random.RVar.Enum() where++import Data.Random.RVar+import Data.Random.Distribution+import Data.Random.Distribution.Uniform+import Control.Applicative((<$>))++-- TODO: Send to library author as a "missing instance"+instance (Enum a) => Distribution Uniform a where+ rvarT (Uniform l h) = toEnum <$> uniformT (fromEnum l) (fromEnum h)+
WordPass.hs view
@@ -1,6 +1,7 @@ -- | Main module generating passwords. module Main where +import System.IO (hFlush, stdout) import System.Directory(getDirectoryContents) import qualified Data.Text as Text import qualified Data.Text.IO as Text@@ -37,9 +38,14 @@ defaultDictDir = "/usr/share/dict" -- | Read a set of dictionaries and put the together.-readDicts filenames = (V.fromList . Set.toList) `fmap` foldM action Set.empty filenames+readDicts filenames = do putStr $ "Reading " ++ show (length filenames) ++ " files"+ result <- (V.fromList . Set.toList) `fmap` foldM action Set.empty filenames+ putStrLn ""+ return result where action currentSet filename = do newSet <- readDict filename+ putStr "."+ hFlush stdout return $! Set.fromList (V.toList newSet) `Set.union` currentSet -- | Read all dictionaries from a given directory.@@ -90,7 +96,7 @@ symbolSeparator = Text.singleton <$> randomElement symbolChars main = do dictWords <- readDictDir defaultDictDir- --print $ V.length dictWords+ putStrLn $ "Read " ++ show (V.length dictWords) ++ " words from dictionaries." putStr "Estimated password strength (bits): " print $ randomPasswordStrength dictWords numWs replicateM 5 $ do
wordpass.cabal view
@@ -1,16 +1,14 @@--- Initial wordpass.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/- name: wordpass-version: 0.1.0.0+version: 0.2.0.0 synopsis: Dictionary-based password generator--- description: +description: This script reads dict word lists and generates word-based passwords.+ Not unlike http://xkcd.com/936/. homepage: https://github.com/mjgajda/wordpass license: BSD3 license-file: LICENSE author: Michal J. Gajda maintainer: mjgajda@gmail.com--- copyright: +copyright: Michal J. Gajda category: System build-type: Simple extra-source-files: README.md@@ -18,7 +16,7 @@ executable wordpass main-is: WordPass.hs- -- other-modules: Data.Random.RVar.Enum + other-modules: Data.Random.RVar.Enum other-extensions: OverlappingInstances, MultiParamTypeClasses, FlexibleInstances build-depends: base >=4.6 && <4.7, text >=1.1 && <1.2, containers >=0.5 && <0.6, random-fu >=0.2 && <0.3, random-source >=0.3 && <0.4, vector >=0.10 && <0.11, directory >= 1.2 && < 1.4 -- hs-source-dirs: