crypton-1.0.0: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | Good
Safe Haskell | None
Language | Haskell2010

Crypto.Number.Serialize.LE

Description

Fast serialization primitives for integer (little endian)

Synopsis

- i2osp :: ByteArray ba => Integer -> ba
- os2ip :: ByteArrayAccess ba => ba -> Integer
- i2ospOf :: ByteArray ba => Int -> Integer -> Maybe ba
- i2ospOf_ :: ByteArray ba => Int -> Integer -> ba

# Documentation

i2osp :: ByteArray ba => Integer -> ba #

`i2osp` converts a positive integer into a byte string.

The first byte is LSB (least significant byte); the last byte is the MSB (most significant byte)

os2ip :: ByteArrayAccess ba => ba -> Integer #

`os2ip` converts a byte string into a positive integer.

i2ospOf :: ByteArray ba => Int -> Integer -> Maybe ba #

Just like `i2osp`, but takes an extra parameter for size. If the number is too big to fit in `len` bytes, `Nothing` is returned otherwise the number is padded with 0 to fit the `len` required.

i2ospOf_ :: ByteArray ba => Int -> Integer -> ba #

Just like `i2ospOf` except that it doesn't expect a failure: i.e. an integer larger than the number of output bytes requested.

For example if you just took a modulo of the number that represent the size (example the RSA modulo n).