Sha256: cf7e11a220bb383757c3a69f708d4ee2e0d3095c27d2d2c647dacfb7aa99444f
Contents?: true
Size: 649 Bytes
Versions: 3
Compression:
Stored size: 649 Bytes
Contents
module CookieMonster class Encryption < Base def initialize(payload) @aes = ::OpenSSL::Cipher::Cipher.new(configuration.cipher_type) @aes.padding = 1 @key = Digest::SHA256.digest(configuration.key) @payload = payload end def encrypt @aes.encrypt @aes.key = @key @aes.update(@payload) + @aes.final end def decrypt @aes.decrypt @aes.key = @key @aes.update(@payload) + @aes.final rescue OpenSSL::Cipher::CipherError raise PasswordInvalid, "Password incorrect!" end class PasswordInvalid < Exception def initialize(s); s; end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cookie_monster-0.1.1 | lib/cookie_monster/encryption.rb |
cookie_monster-0.0.1 | lib/cookie_monster/encryption.rb |
cookie_monster-0.0.0 | lib/cookie_monster/encryption.rb |