class
Message::Encryptor
- Message::Encryptor
- Reference
- Object
Defined in:
message/encryptor.crConstant Summary
-
KEY_LENGTH =
32 -
AES-256 requires a 32-byte key
Constructors
Instance Method Summary
- #decrypt(value : Bytes) : Bytes
- #encrypt(value) : Bytes
-
#encrypt_and_sign(value : Slice(UInt8)) : String
Encrypt and sign a message.
- #encrypt_and_sign(value : String) : String
- #verifier : Verifier
-
#verify_and_decrypt(value : String) : Bytes
Verify and Decrypt a message.
Constructor Detail
def self.new(secret : String, cipher_algorithm : String = "aes-256-cbc", digest : Symbol = :sha256, fallback_digest : Symbol | Nil = :sha1, use_kdf : Bool = false, kdf_iterations : Int32 = 100000, kdf_salt : String = "session_kdf_salt")
#
Instance Method Detail
def encrypt_and_sign(value : Slice(UInt8)) : String
#
Encrypt and sign a message. We need to sign the message in order to avoid padding attacks. Reference: http://www.limited-entropy.com/padding-oracle-attacks.
def verify_and_decrypt(value : String) : Bytes
#
Verify and Decrypt a message. We need to verify the message in order to avoid padding attacks. Reference: http://www.limited-entropy.com/padding-oracle-attacks.