class

Crypt::Crypter

Inherits Reference / Object

Encrypt / Decrypt using OpenSSL Cipher. See https://crystal-lang.org/api/OpenSSL/Cipher.html

Constructors

new(secret : String, digest : Symbol = :sha1, cipher_algo : String = "aes-256-cbc")

Creates a new Crypter instance.

Source

Instance methods

cipher_decrypt(value : Bytes) : Bytes

Decrypt value encrypted by cipher_encrypt.

Source
cipher_encrypt(value) : Bytes

Encrypt the value which should be decrypted by cipher_decrypt. See also encrypt, encrypt_and_sign.

Source
decrypt(value : Bytes, kind : Symbol, sign_error = Signer::INVALID_SIGN) : Bytes

Equivalent to verify_and_decrypt, just a shortcut.

Source
decrypt(value : String, kind : Symbol, sign_error = Signer::INVALID_SIGN) : Bytes

Equivalent to verify_and_decrypt, just a shortcut.

Source
decrypt(value : Bytes) : Bytes

Equivalent to cipher_decrypt, just a shortcut.

Source
encrypt(value : Bytes, kind : Symbol) : String

Equivalent to encrypt_and_sign, just a shortcut.

Source
encrypt(value : String, kind : Symbol) : String

Equivalent to encrypt_and_sign, just a shortcut.

Source
encrypt(value) : Bytes

Equivalent to cipher_encrypt, just a shortcut.

Source
encrypt_and_sign(value : Bytes) : String

Encrypt and sign a value. We need to sign the value in order to avoid padding attacks. Reference: http://www.limited-entropy.com/padding-oracle-attacks.

Source
encrypt_and_sign(value : String) : String

Encrypt and sign a value. We need to sign the value in order to avoid padding attacks. Reference: http://www.limited-entropy.com/padding-oracle-attacks.

Source
signer
Source
verify_and_decrypt(value : String, sign_error = Signer::INVALID_SIGN) : Bytes

Verify and decrypt a signed value. We need to verify the value in order to avoid padding attacks. Reference: http://www.limited-entropy.com/padding-oracle-attacks.

Source
verify_and_decrypt(value : Bytes, sign_error = Signer::INVALID_SIGN) : Bytes

Verify and decrypt a signed value. We need to verify the value in order to avoid padding attacks. Reference: http://www.limited-entropy.com/padding-oracle-attacks.

Source