Class: Rack::Session::EncryptedCookie

Inherits:
Cookie
  • Object
show all
Defined in:
lib/rack/session/encrypted_cookie.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ EncryptedCookie

Returns a new instance of EncryptedCookie.



9
10
11
12
13
14
15
16
17
18
# File 'lib/rack/session/encrypted_cookie.rb', line 9

def initialize(app, options = {})
  super
  @salt = options.fetch(:salt, 'encrypted cookie')
  @signed_salt = options.fetch(:signed_salt, 'signed encrypted cookie')
  @iterations = options.fetch(:iterations, 1024)
  @key_size = options.fetch(:key_size, 64)
  @cipher = OpenSSL::Cipher::Cipher.new(options.fetch(:cipher, 'AES-256-CBC'))
  @cipher_secrets = @secrets.map { |secret| generate_key(secret, @salt) }
  @secrets.map! { |secret| generate_key(secret, @signed_salt) }
end