2013-08-09 17:19:22 +02:00
|
|
|
|
|
|
|
-- | Password scatterer.
|
2014-04-26 00:15:11 +02:00
|
|
|
module Scat (scatter) where
|
2013-08-09 17:19:22 +02:00
|
|
|
|
2013-08-11 20:18:11 +02:00
|
|
|
import Data.Monoid
|
2013-08-14 17:15:52 +02:00
|
|
|
import Data.ByteString (ByteString, unpack)
|
2013-08-09 17:19:22 +02:00
|
|
|
import qualified Data.ByteString.Char8 as C
|
2013-08-10 00:13:45 +02:00
|
|
|
import Crypto.Scrypt
|
2013-08-09 17:19:22 +02:00
|
|
|
|
2013-08-12 18:10:36 +02:00
|
|
|
-- | Generates the seed integer given a service, a password and a code.
|
2013-08-11 20:18:11 +02:00
|
|
|
scatter :: ByteString -> ByteString -> ByteString -> Integer
|
|
|
|
scatter k pw c = foldr (\ n s -> fromIntegral n + 256 * s) 0 $
|
2014-04-14 04:20:49 +02:00
|
|
|
unpack $ getHash $ scrypt params (Salt k) (Pass $ pw <> c)
|
2013-08-12 18:10:36 +02:00
|
|
|
where
|
|
|
|
Just params = scryptParams 14 8 50
|