Class: Rage::Cookies::EncryptedJar
- Inherits:
-
Object
- Object
- Rage::Cookies::EncryptedJar
- Defined in:
- lib/rage/cookies.rb
Constant Summary collapse
- SALT =
"encrypted cookie"
- PADDING =
"00"
Class Method Summary collapse
Class Method Details
.dump(value) ⇒ Object
203 204 205 206 207 |
# File 'lib/rage/cookies.rb', line 203 def dump(value) # add two bytes to hold meta information, e.g. in case we # need to change the encryption algorithm in the future Base64.urlsafe_encode64(PADDING + primary_box.encrypt(value.to_s)) end |
.load(value) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/rage/cookies.rb', line 187 def load(value) box = primary_box begin box.decrypt(Base64.urlsafe_decode64(value).byteslice(2..)) rescue ArgumentError nil rescue RbNaCl::CryptoError i ||= 0 if (box = fallback_boxes[i]) i += 1 retry end end end |