Class: Auther::Cipher

Inherits:
Object
  • Object
show all
Defined in:
lib/auther/cipher.rb

Overview

Manages encryption/decryption.

Instance Method Summary collapse

Constructor Details

#initialize(secret) ⇒ Cipher

Returns a new instance of Cipher.



6
7
8
# File 'lib/auther/cipher.rb', line 6

def initialize secret
  @encryptor = ActiveSupport::MessageEncryptor.new secret
end

Instance Method Details

#decrypt(data) ⇒ Object



14
15
16
# File 'lib/auther/cipher.rb', line 14

def decrypt data
  encryptor.decrypt_and_verify data
end

#encrypt(data) ⇒ Object



10
11
12
# File 'lib/auther/cipher.rb', line 10

def encrypt data
  encryptor.encrypt_and_sign data
end