Class: Glib::Crypt::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/glib/crypt/utils.rb

Class Method Summary collapse

Class Method Details

.decrypt(encrypted_message, encryption_secret, encryption_salt) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/glib/crypt/utils.rb', line 9

def self.decrypt(encrypted_message, encryption_secret, encryption_salt)
  encryptor = message_encryptor(encryption_secret, encryption_salt)
  begin
    encryptor.decrypt_and_verify(CGI.unescape(encrypted_message))
  rescue ActiveSupport::MessageEncryptor::InvalidMessage
    nil
  end
end

.encrypt(original_message, encryption_secret, encryption_salt) ⇒ Object



4
5
6
7
# File 'lib/glib/crypt/utils.rb', line 4

def self.encrypt(original_message, encryption_secret, encryption_salt)
  encryptor = message_encryptor(encryption_secret, encryption_salt)
  CGI.escape(encryptor.encrypt_and_sign(original_message))
end