crypto-classical-0.3.0: An educational tool for studying classical cryptography schemes.

Copyright(c) Colin Woodbury 2015 - 2020
LicenseBSD3
MaintainerColin Woodbury <colin@fosskers.ca>
Safe HaskellNone
LanguageHaskell2010

Crypto.Classical.Util

Contents

Description

 
Synopsis

Character Conversion

letter :: ( / 26) -> Char Source #

int :: Char -> / 26 Source #

Modular Arithmetic

inverse :: ( / 26) -> / 26 Source #

Must be passed a number coprime with 26.

Random Numbers

rseq :: CPRG g => g -> Integer -> [Integer] Source #

The sequence (r1,...r[n-1]) of numbers such that r[i] is an independent sample from a uniform random distribution [0..n-i]

Map function

mapInverse :: (Ord k, Ord v) => Map k v -> Map v k Source #

Invert a Map. Keys become values, values become keys. Note that this operation may result in a smaller Map than the original.

compose :: (Ord k, Ord v) => Map k v -> Map v v' -> Map k v' Source #

Compose two Maps. If some key v isn't present in the second Map, then k will be left out of the result.

2015 April 16 @ 13:56 Would it be possible to make a Category for Map like this?

(|.|) :: (Ord k, Ord v) => Map k v -> Map v v' -> Map k v' Source #

An alias for compose. Works left-to-right.

Miscellaneous

uniZip :: [a] -> [(a, a)] Source #

Zip a list on itself. Takes pairs of values and forms a tuple. Example:

>>> uniZip [1,2,3,4,5,6]
[(1,2),(3,4),(5,6)]

stretch :: [a] -> [a] Source #

Stretch the contents of a list. List becomes twice a long. List must be finite. Example:

>>> stretch [1,2,3,4]
[1,1,2,2,3,3,4,4]

both :: (a -> b) -> (a, a) -> (b, b) Source #