Class: Nyauth::Encryptor

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/nyauth/encryptor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEncryptor

Returns a new instance of Encryptor.



11
12
13
# File 'lib/nyauth/encryptor.rb', line 11

def initialize
  @encryptor = ::ActiveSupport::MessageEncryptor.new(Nyauth.configuration.encryption_secret, cipher: @@cipher, digest: @@digest)
end

Instance Attribute Details

#encryptorObject (readonly)

Returns the value of attribute encryptor.



9
10
11
# File 'lib/nyauth/encryptor.rb', line 9

def encryptor
  @encryptor
end

Class Method Details

.decrypt(encrypted_message) ⇒ Object



20
21
22
# File 'lib/nyauth/encryptor.rb', line 20

def decrypt(encrypted_message)
  instance.encryptor.decrypt_and_verify(encrypted_message)
end

.encrypt(message) ⇒ Object



16
17
18
# File 'lib/nyauth/encryptor.rb', line 16

def encrypt(message)
  instance.encryptor.encrypt_and_sign(message)
end