class Auther::Cipher
Manages encryption/decryption.
Constants
- BYTE_DIVISOR
Attributes
encryptor[R]
Public Class Methods
generate(login, password)
click to toggle source
# File lib/auther/cipher.rb, line 8 def self.generate login, password secret = SecureRandom.hex key_length / BYTE_DIVISOR cipher = new secret { secret: secret, login: cipher.encrypt(login), password: cipher.encrypt(password) } end
key_length()
click to toggle source
# File lib/auther/cipher.rb, line 19 def self.key_length ActiveSupport::MessageEncryptor.key_len end
new(secret)
click to toggle source
# File lib/auther/cipher.rb, line 23 def initialize secret @encryptor = ActiveSupport::MessageEncryptor.new secret end
Public Instance Methods
decrypt(data)
click to toggle source
# File lib/auther/cipher.rb, line 31 def decrypt data encryptor.decrypt_and_verify data end
encrypt(data)
click to toggle source
# File lib/auther/cipher.rb, line 27 def encrypt data encryptor.encrypt_and_sign data end