Skip to content

Commit

Permalink
Expose underlying encrypt function used by Auth
Browse files Browse the repository at this point in the history
  • Loading branch information
ozataman committed Jan 12, 2012
1 parent 0645e4b commit 6047c55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Snap/Snaplet/Auth.hs
Expand Up @@ -49,6 +49,7 @@ module Snap.Snaplet.Auth
-- * Other Utilities
, withBackend
, encryptPassword
, encrypt
, checkPassword
, authenticatePassword
, setPassword
Expand Down
15 changes: 10 additions & 5 deletions src/Snap/Snaplet/Auth/Types.hs
Expand Up @@ -34,14 +34,19 @@ defaultStrength :: Int
defaultStrength = 12


-------------------------------------------------------------------------------
-- | The underlying encryption function, in case you need it for
-- external processing.
encrypt :: ByteString -> IO ByteString
encrypt = flip makePassword defaultStrength


------------------------------------------------------------------------------
-- Turn a 'ClearText' password into an 'Encrypted' password, ready to be
-- stuffed into a database.
-- | Turn a 'ClearText' password into an 'Encrypted' password, ready to
-- be stuffed into a database.
encryptPassword :: Password -> IO Password
encryptPassword p@(Encrypted {}) = return p
encryptPassword (ClearText p) = do
hashed <- makePassword p defaultStrength
return $ Encrypted hashed
encryptPassword (ClearText p) = Encrypted `fmap` encrypt p


------------------------------------------------------------------------------
Expand Down

0 comments on commit 6047c55

Please sign in to comment.