mirror of
https://github.com/redelmann/scat
synced 2025-01-10 06:34:20 +01:00
Using Scrypt instead of SHA-512.
This commit is contained in:
parent
b18c63c837
commit
b44ea90397
@ -10,7 +10,7 @@ name: scat
|
|||||||
-- PVP summary: +-+------- breaking API changes
|
-- PVP summary: +-+------- breaking API changes
|
||||||
-- | | +----- non-breaking API additions
|
-- | | +----- non-breaking API additions
|
||||||
-- | | | +--- code changes with no API change
|
-- | | | +--- code changes with no API change
|
||||||
version: 0.1.0.0
|
version: 0.2.0.0
|
||||||
|
|
||||||
-- A short (one-line) description of the package.
|
-- A short (one-line) description of the package.
|
||||||
synopsis: Generates unique passwords for various websites from a single password.
|
synopsis: Generates unique passwords for various websites from a single password.
|
||||||
@ -57,5 +57,5 @@ executable scat
|
|||||||
other-modules: Scat.Builder, Scat.Schemas, Scat.Options, Scat.Utils.Permutation, Paths_scat
|
other-modules: Scat.Builder, Scat.Schemas, Scat.Options, Scat.Utils.Permutation, Paths_scat
|
||||||
|
|
||||||
-- Other library packages from which modules are imported.
|
-- Other library packages from which modules are imported.
|
||||||
build-depends: base ==4.5.*, SHA ==1.6.*, bytestring ==0.9.*, optparse-applicative ==0.5.*, mtl ==2.1.*, vector ==0.10.*
|
build-depends: base ==4.5.*, scrypt ==0.3.*, bytestring ==0.9.*, optparse-applicative ==0.5.*, mtl ==2.1.*, vector ==0.10.*
|
||||||
|
|
18
src/Scat.hs
18
src/Scat.hs
@ -3,16 +3,14 @@
|
|||||||
-- | Password scatterer.
|
-- | Password scatterer.
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
import Data.Monoid
|
import Data.ByteString (ByteString)
|
||||||
import Data.Digest.Pure.SHA
|
import Data.ByteString (unpack)
|
||||||
import Data.ByteString.Lazy (ByteString)
|
|
||||||
import qualified Data.ByteString.Char8 as C
|
import qualified Data.ByteString.Char8 as C
|
||||||
import qualified Data.ByteString.Lazy.Char8 as LC
|
|
||||||
import qualified Data.ByteString.Lazy as BS
|
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
|
import Crypto.Scrypt
|
||||||
|
|
||||||
import Scat.Schemas
|
import Scat.Schemas
|
||||||
import Scat.Builder
|
import Scat.Builder
|
||||||
@ -20,7 +18,10 @@ import Scat.Options
|
|||||||
|
|
||||||
-- | Generates the seed integer given a key and a password.
|
-- | Generates the seed integer given a key and a password.
|
||||||
scatter :: ByteString -> ByteString -> Integer
|
scatter :: ByteString -> ByteString -> Integer
|
||||||
scatter k pw = integerDigest $ sha512 (k <> pw)
|
scatter k pw = foldr (\ c s -> fromIntegral c + 256 * s) 0 $
|
||||||
|
unpack $ unHash $ scrypt params (Salt k) (Pass pw)
|
||||||
|
where
|
||||||
|
Just params = scryptParams 14 8 50
|
||||||
|
|
||||||
-- | Main type of the program.
|
-- | Main type of the program.
|
||||||
type Scat a = ReaderT Options IO a
|
type Scat a = ReaderT Options IO a
|
||||||
@ -55,7 +56,7 @@ printVerbose str = do
|
|||||||
getPassword :: Scat ByteString
|
getPassword :: Scat ByteString
|
||||||
getPassword = do
|
getPassword = do
|
||||||
mpw <- fmap password ask
|
mpw <- fmap password ask
|
||||||
pw <- case mpw of
|
case mpw of
|
||||||
-- Ask for the password on stdin.
|
-- Ask for the password on stdin.
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
c <- fmap confirm ask
|
c <- fmap confirm ask
|
||||||
@ -65,7 +66,6 @@ getPassword = do
|
|||||||
|
|
||||||
-- Retrieve the password from the arguments.
|
-- Retrieve the password from the arguments.
|
||||||
Just st -> return $ C.pack st
|
Just st -> return $ C.pack st
|
||||||
return $ BS.fromChunks [pw]
|
|
||||||
where
|
where
|
||||||
getPass = askPassword "Password: "
|
getPass = askPassword "Password: "
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ askPassword str = do
|
|||||||
|
|
||||||
-- | Gets the key.
|
-- | Gets the key.
|
||||||
getKey :: Scat ByteString
|
getKey :: Scat ByteString
|
||||||
getKey = fmap (LC.pack . key) ask
|
getKey = fmap (C.pack . key) ask
|
||||||
|
|
||||||
-- | Gets the schema to generate the new password.
|
-- | Gets the schema to generate the new password.
|
||||||
getSchema :: Scat Schema
|
getSchema :: Scat Schema
|
||||||
|
Loading…
Reference in New Issue
Block a user