billstclair / elm-crypto-string / Crypto.Strings

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

Functions

encrypt : Random.Seed -> Types.Passphrase -> Types.Plaintext -> Result String ( Types.Ciphertext, Random.Seed )

Encrypt a string. Encode the output as Base64 with 80-character lines.

The Seed parameter is a Random.Seed, as created by Random.initialSeed

See Crypto.Strings.Crypt.encrypt for more options.

This shouldn't ever return an error, but since the key generation can possibly do so, it returns a Result instead of just (Ciphertext, randomState).

justEncrypt : Random.Seed -> Types.Passphrase -> Types.Plaintext -> Types.Ciphertext

Testing function. Just returns the result with no random generator update.

decrypt : Types.Passphrase -> Types.Ciphertext -> Result String Types.Plaintext

Decrypt a string created with encrypt.

See Crypto.Strings.Crypt.decrypt for more options.

This can get errors if the ciphertext you pass in decrypts to something that isn't a UTF-8 string.