cryptonite-0.20: Cryptography Primitives sink

LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
PortabilityGood
Safe HaskellNone
LanguageHaskell2010

Crypto.Number.Serialize

Description

fast serialization primitives for integer

Synopsis

Documentation

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

i2osp converts a positive integer into a byte string

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

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

os2ip converts a byte string into a positive integer

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

just like i2osp, but take 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 Source #

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).