billstclair/elm-crypto-string/1.0.2

NOTE: this package is not compatible with Elm 0.19.1

Crypto.Strings.Crypt

Block chaining and string encryption for use with any block cipher.

Types

type alias DefaultKey =
Key Key

Default key type.

Functions

Config key state randomState
-> Passphrase
-> Result String (Key key)

Expand a key preparing it for use with encrypt or decrypt.

defaultConfig : Config Key CtrState randomState

Default configuration.

Config key state randomState
-> RandomGenerator randomState
-> Key key
-> Plaintext
-> ( Ciphertext, randomState )

Encrypt a string.

Config key state randomState
-> Key key
-> Ciphertext
-> Result Plaintext String

Decrypt a string created with encrypt.

seedGenerator : Seed -> RandomGenerator Seed

A random generator that takes and returns a standard Elm Seed.

Low-level functions

listToBlocks : Int -> List Int -> List Block

Convert a list of integers into a list of blocks.

The end of the last block will always be #x80 plus zeroes. If all the blocks are full, and the last byte is NOT zero or #x80, then no padding is added.

blocksToList : List Block -> List Int

Convert a list of blocks into a list of integers.

padLastBlock : Int -> List Block -> List Block

Put a 0x80 at the end of the last block, and pad with zeroes.

No padding is done if the last block is of the blockSize, and does NOT already end with 0 or 0x80.

unpadLastBlock : List Block -> List Block

Remove the padding added by padLastBlock from the last block in a list.

stripTrailingZeroes : Block -> Block

Strip the trailing zeroes from a block.