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

Description

Synopsis

- sqrti :: Integer -> (Integer, Integer)
- gcde :: Integer -> Integer -> (Integer, Integer, Integer)
- areEven :: [Integer] -> Bool
- log2 :: Integer -> Int
- numBits :: Integer -> Int
- numBytes :: Integer -> Int
- asPowerOf2AndOdd :: Integer -> (Int, Integer)

# Documentation

sqrti :: Integer -> (Integer, Integer) #

`sqrti` returns two integers `(l,b)` so that `l <= sqrt i <= b`. The implementation is quite naive, use an approximation for the first number and use a dichotomy algorithm to compute the bound relatively efficiently.

gcde :: Integer -> Integer -> (Integer, Integer, Integer) #

Get the extended GCD of two integer using integer divMod

gcde `a` `b` find (x,y,gcd(a,b)) where ax + by = d

areEven :: [Integer] -> Bool #

Check if a list of integer are all even

log2 :: Integer -> Int #

Compute the binary logarithm of a integer

numBits :: Integer -> Int #

Compute the number of bits for an integer

numBytes :: Integer -> Int #

Compute the number of bytes for an integer

asPowerOf2AndOdd :: Integer -> (Int, Integer) #

Express an integer as an odd number and a power of 2