class Crypt::Crypter

Overview

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

Defined in:

crypter.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(secret : String, digest = :sha1, cipher_algo = "aes-256-cbc") #

Creates a new Crypter instance.


Instance Method Detail

def cipher_decrypt(value : Bytes) : Bytes #

Decrypt value encrypted by #cipher_encrypt.


def cipher_encrypt(value) : Bytes #

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


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

Equivalent to #verify_and_decrypt, just a shortcut.


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

Equivalent to #verify_and_decrypt, just a shortcut.


def decrypt(value : Bytes) : Bytes #

Equivalent to #cipher_decrypt, just a shortcut.


def encrypt(value : Bytes, kind : Symbol) : String #

Equivalent to #encrypt_and_sign, just a shortcut.


def encrypt(value : String, kind : Symbol) : String #

Equivalent to #encrypt_and_sign, just a shortcut.


def encrypt(value) : Bytes #

Equivalent to #cipher_encrypt, just a shortcut.


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


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


def signer : Signer #

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


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