| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
System.Gnu.CryptR
Description
This package wraps glibc's crypt_r function in a thread-safe manner.
$ ghci -XOverloadedStrings GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude> :m + System.Gnu.CryptR Data.ByteString.Char8 Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptR' \"password\" \"l3\" Loading package bytestring-0.9.1.7 ... linking ... done. Loading package nano-cryptr-0.1.1.1 ... linking ... done. \"l3vmImyenGFYg\" Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptR' \"password1\" \"l3vmImyenGFYg\" \"l3vmImyenGFYg\" Prelude System.Gnu.CryptR Data.ByteString.Char8> x <- 'newCryptData' Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptRIO' x \"password1\" \"l3vmImyenGFYg\" \"l3vmImyenGFYg\" Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptRIO' x \"xpassword\" \"l3vmImyenGFYg\" \"l3odRN01x86RU\" Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptRIO' x \"password\" \"l3vmImyenGFYg\" \"l3vmImyenGFYg\" Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptRIO' x \"password\" \"$1$grufal$\" \"$1$grufal$KyfLpXJJ32ZZw9EqqMSav1\" Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptRIO' x \"password1\" \"$1$grufal$\" \"$1$grufal$xi8N0nP2Fl22TxyW68uvV.\" Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptRIO' x \"password1\" \"$1$grufal$KyfLpXJJ32ZZw9EqqMSav1\" \"$1$grufal$xi8N0nP2Fl22TxyW68uvV.\" Prelude System.Gnu.CryptR Data.ByteString.Char8> 'cryptRIO' x \"password\" \"$1$grufal$KyfLpXJJ32ZZw9EqqMSav1\" \"$1$grufal$KyfLpXJJ32ZZw9EqqMSav1\"
Synopsis
- data CryptData
- newCryptData :: IO CryptData
- cryptRIO :: CryptData -> ByteString -> ByteString -> IO (Maybe ByteString)
- cryptR :: ByteString -> ByteString -> Maybe ByteString
Documentation
CryptData is an opaque wrapper around the state used by
crypt_r.
newCryptData :: IO CryptData Source #
Create a new CryptData value. It uses ForeignPtr to free the
underlying data structure properly when it is garbage collected.
Arguments
| :: CryptData | the |
| -> ByteString | the |
| -> ByteString | the |
| -> IO (Maybe ByteString) | the result of the call to |
This is a thread-safe interface to the functionality provided by
glibc's crypt_r. It protects against concurrent use of the
same CryptData value internally. This means that it's
potentially a performance bottleneck, and you may wish to use
multiple CryptData values if high concurrency is necessary.
This interface avoids initializing a new CryptData for each call,
as is done by the cryptR call
Arguments
| :: ByteString | the |
| -> ByteString | the |
| -> Maybe ByteString | the result of the call to |
This is a pure, thread-safe interface to the functionality
provided by glibc's crypt_r. It uses crypt_r internally,
allocating a single-use buffer for each call. Because the buffer
is decently large and needs to be initialized for each call, this
function has significantly more overhead on multiple calls than
using newCryptData followed by multiple uses of cryptRIO. This
is provided as a convenience function when the overhead is not as
important as the simplicity of this interface.
Because crypt_r may fail (for example, when given an invalid salt), this
function returns a 'Maybe ByteString'.