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
|
||||
-- | | +----- non-breaking API additions
|
||||
-- | | | +--- code changes with no API change
|
||||
version: 0.1.0.0
|
||||
version: 0.2.0.0
|
||||
|
||||
-- A short (one-line) description of the package.
|
||||
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 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.
|
||||
module Main (main) where
|
||||
|
||||
import Data.Monoid
|
||||
import Data.Digest.Pure.SHA
|
||||
import Data.ByteString.Lazy (ByteString)
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.ByteString (unpack)
|
||||
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.Exit
|
||||
import Control.Exception
|
||||
import Control.Monad.Reader
|
||||
import Crypto.Scrypt
|
||||
|
||||
import Scat.Schemas
|
||||
import Scat.Builder
|
||||
@ -20,7 +18,10 @@ import Scat.Options
|
||||
|
||||
-- | Generates the seed integer given a key and a password.
|
||||
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.
|
||||
type Scat a = ReaderT Options IO a
|
||||
@ -55,7 +56,7 @@ printVerbose str = do
|
||||
getPassword :: Scat ByteString
|
||||
getPassword = do
|
||||
mpw <- fmap password ask
|
||||
pw <- case mpw of
|
||||
case mpw of
|
||||
-- Ask for the password on stdin.
|
||||
Nothing -> do
|
||||
c <- fmap confirm ask
|
||||
@ -65,7 +66,6 @@ getPassword = do
|
||||
|
||||
-- Retrieve the password from the arguments.
|
||||
Just st -> return $ C.pack st
|
||||
return $ BS.fromChunks [pw]
|
||||
where
|
||||
getPass = askPassword "Password: "
|
||||
|
||||
@ -92,7 +92,7 @@ askPassword str = do
|
||||
|
||||
-- | Gets the key.
|
||||
getKey :: Scat ByteString
|
||||
getKey = fmap (LC.pack . key) ask
|
||||
getKey = fmap (C.pack . key) ask
|
||||
|
||||
-- | Gets the schema to generate the new password.
|
||||
getSchema :: Scat Schema
|
||||
|
Loading…
Reference in New Issue
Block a user