Class: Rage::Cookies::EncryptedJar
- Inherits:
-
Object
- Object
- Rage::Cookies::EncryptedJar
show all
- Extended by:
- RbNaClKeyBuilder
- Defined in:
- lib/rage/cookies.rb
Constant Summary
collapse
- PURPOSE =
"encrypted cookie"
- PADDING =
"00"
RbNaClKeyBuilder::RBNACL_MAX_VERSION, RbNaClKeyBuilder::RBNACL_MIN_VERSION
Class Method Summary
collapse
Class Method Details
.dump(value) ⇒ Object
331
332
333
334
335
|
# File 'lib/rage/cookies.rb', line 331
def dump(value)
Base64.urlsafe_encode64(PADDING + primary_box.encrypt(value.to_s))
end
|
.load(value) ⇒ Object
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
# File 'lib/rage/cookies.rb', line 312
def load(value)
box = primary_box
begin
box.decrypt(Base64.urlsafe_decode64(value).byteslice(2..))
rescue ArgumentError
Rage.logger.debug("Failed to decode encrypted cookie")
nil
rescue RbNaCl::CryptoError
Rage.logger.debug("Failed to decrypt encrypted cookie")
i ||= 0
if (box = fallback_boxes[i])
Rage.logger.debug { "Trying to decrypt with fallback key ##{i + 1}" }
i += 1
retry
end
end
end
|