-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Hashids generates short, unique, non-sequential ids from numbers.
--   
--   This is a Haskell port of the Hashids library. It is typically used to
--   encode numbers to a format suitable to appear in visible places like
--   urls. It converts numbers like 347 into strings like yr8, or a list of
--   numbers like [27, 986] into 3kTMd. You can also decode those ids back.
--   This is useful in bundling several parameters into one.
@package hashids
@version 1.0.2.4


-- | This is a Haskell port of Ivan Akimov's Hashids library. This is
--   <i>not</i> a cryptographic hashing algorithm. Hashids is typically
--   used to encode numbers to a format suitable to appear in places like
--   URLs.
--   
--   See the official Hashids home page: <a>http://hashids.org</a>
--   
--   Hashids is a small open-source library that generates short, unique,
--   non-sequential ids from numbers. It converts numbers like 347 into
--   strings like <tt>yr8</tt>, or a list of numbers like [27, 986] into
--   <tt>3kTMd</tt>. You can also decode those ids back. This is useful in
--   bundling several parameters into one or simply using them as short
--   UIDs.
module Web.Hashids

-- | Opaque data type with various internals required for encoding and
--   decoding.
data HashidsContext

-- | Hashids version number.
version :: String

-- | Create a context object using the given salt, a minimum hash length,
--   and a custom alphabet. If you only need to supply the salt, or the
--   first two arguments, use <a>hashidsSimple</a> or <a>hashidsMinimum</a>
--   instead.
--   
--   Changing the alphabet is useful if you want to make your hashes
--   unique, i.e., create hashes different from those generated by other
--   applications relying on the same algorithm.
createHashidsContext :: ByteString -> Int -> String -> HashidsContext

-- | Create a context object using the default alphabet and the provided
--   salt, without any minimum required length.
hashidsSimple :: ByteString -> HashidsContext

-- | Create a context object using the default alphabet and the provided
--   salt. The generated hashes will have a minimum length as specified by
--   the second argument.
hashidsMinimum :: ByteString -> Int -> HashidsContext

-- | Encode a hexadecimal number.
--   
--   <i>Example use:</i>
--   
--   <pre>
--   encodeHex context "ff83"
--   </pre>
encodeHex :: HashidsContext -> String -> ByteString

-- | Decode a hash generated with <a>encodeHex</a>.
--   
--   <i>Example use:</i>
--   
--   <pre>
--   decodeHex context "yzgwD"
--   </pre>
decodeHex :: HashidsContext -> ByteString -> String

-- | Encode a single number.
--   
--   <i>Example use:</i>
--   
--   <pre>
--   let context = hashidsSimple "this is my salt"
--       hash = encode context 5        -- == "rD"
--   </pre>
encode :: HashidsContext -> Int -> ByteString

-- | Encode a list of numbers.
--   
--   <i>Example use:</i>
--   
--   <pre>
--   let context = hashidsSimple "this is my salt"
--       hash = encodeList context [2, 3, 5, 7, 11]          -- == "EOurh6cbTD"
--   </pre>
encodeList :: HashidsContext -> [Int] -> ByteString

-- | Decode a hash.
--   
--   <i>Example use:</i>
--   
--   <pre>
--   let context = hashidsSimple "this is my salt"
--       hash = decode context "rD"        -- == [5]
--   </pre>
decode :: HashidsContext -> ByteString -> [Int]

-- | Encode a number using the provided salt.
--   
--   This convenience function creates a context with the default alphabet.
--   If the same context is used repeatedly, use <a>encode</a> with one of
--   the constructors instead.
encodeUsingSalt :: ByteString -> Int -> ByteString

-- | Encode a list of numbers using the provided salt.
--   
--   This function wrapper creates a context with the default alphabet. If
--   the same context is used repeatedly, use <a>encodeList</a> with one of
--   the constructors instead.
encodeListUsingSalt :: ByteString -> [Int] -> ByteString

-- | Decode a hash using the provided salt.
--   
--   This convenience function creates a context with the default alphabet.
--   If the same context is used repeatedly, use <a>decode</a> with one of
--   the constructors instead.
decodeUsingSalt :: ByteString -> ByteString -> [Int]

-- | Shortcut for <a>encodeHex</a>.
encodeHexUsingSalt :: ByteString -> String -> ByteString

-- | Shortcut for <a>decodeHex</a>.
decodeHexUsingSalt :: ByteString -> ByteString -> String
