crypto-numbers-0.1.0: Cryptographic numbers: functions and algorithms

Safe HaskellNone




i2osp :: Integer -> ByteStringSource

i2osp converts a positive integer into a byte string

os2ip :: ByteString -> IntegerSource

os2ip converts a byte string into a positive integer

i2ospOf :: Int -> Integer -> Maybe ByteStringSource

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.

FIXME: use unsafeCreate to fill the bytestring

i2ospOf_ :: Int -> Integer -> ByteStringSource

just like i2ospOf except that it doesn't expect a failure. for example if you just took a modulo of the number that represent the size (example the RSA modulo n).

lengthBytes :: Integer -> IntSource

returns the number of bytes to store an integer with i2osp

FIXME: really slow implementation. use log or bigger shifts.