require 'cgi'
require 'json'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base)
cookie = CGI::unescape(cookie)
salt = 'encrypted cookie'
signed_salt = 'signed encrypted cookie'
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len]
sign_secret = key_generator.generate_key(signed_salt)
encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: JSON)
encryptor.decrypt_and_verify(cookie)
end
Code Example |
---|
Ruby :: rspec change matcher |
Ruby :: logback grails log in different files |
Ruby :: send email rails c one line |
Ruby :: class ruby |
Ruby :: ruby on rails project |
Ruby :: i am working in ruby 2.6 how to jump to a lower version |
R :: outlier tagging boxplot r |
R :: how to fill na values in r |
R :: remove elements from character vector in r |
R :: normalization in r |
R :: rmarkdown section title as variable ## |
R :: r test normality |
R :: view table/dataframe in r |
R :: rename columns in table r |
R :: text in ggplot2 |
R :: how to change the index of a dataframe in r |
R :: export csv file in r |
R :: convert string to lowercase R |
R :: mean in r |
R :: mutual information in r |
R :: r rep() |
R :: r select rows |
R :: ggplot2 reverse order of scale_brewer color |
R :: not displaying prints and on.exit in r |
R :: r create intervals cut |
R :: how to upload multiple excel files r |
R :: r studio |
Rust :: get random enum rust |
Rust :: rust count occurrences of a substring |
Rust :: rust string to f64 |