Permalink
Browse files

Expose underlying encrypt function used by Auth

  • Loading branch information...
1 parent 0645e4b commit 6047c55d29562c3715aa4c7333ecc6d15c6124d4 @ozataman ozataman committed Jan 12, 2012
Showing with 11 additions and 5 deletions.
  1. +1 −0 src/Snap/Snaplet/Auth.hs
  2. +10 −5 src/Snap/Snaplet/Auth/Types.hs
@@ -49,6 +49,7 @@ module Snap.Snaplet.Auth
-- * Other Utilities
, withBackend
, encryptPassword
+ , encrypt
, checkPassword
, authenticatePassword
, setPassword
@@ -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
------------------------------------------------------------------------------

0 comments on commit 6047c55

Please sign in to comment.