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 : Symbol = :sha1, cipher_algo : String = "aes-256-cbc") #

Creates a new Crypter instance.


[View source]

Instance Method Detail

def cipher_decrypt(value : Bytes) : Bytes #

Decrypt value encrypted by #cipher_encrypt.


[View source]
def cipher_encrypt(value) : Bytes #

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


[View source]
def decrypt(value : Bytes, kind : Symbol, sign_error = Signer::INVALID_SIGN) : Bytes #

Equivalent to #verify_and_decrypt, just a shortcut.


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

Equivalent to #verify_and_decrypt, just a shortcut.


[View source]
def decrypt(value : Bytes) : Bytes #

Equivalent to #cipher_decrypt, just a shortcut.


[View source]
def encrypt(value : Bytes, kind : Symbol) : String #

Equivalent to #encrypt_and_sign, just a shortcut.


[View source]
def encrypt(value : String, kind : Symbol) : String #

Equivalent to #encrypt_and_sign, just a shortcut.


[View source]
def encrypt(value) : Bytes #

Equivalent to #cipher_encrypt, just a shortcut.


[View source]
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.


[View source]
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.


[View source]
def signer : Signer #

[View source]
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.


[View source]
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.


[View source]