Sha256: 379fef1f020a794ebf7922ef89131afc6e52d660d4cb1e729937e79e14582789
Contents?: true
Size: 661 Bytes
Versions: 12
Compression:
Stored size: 661 Bytes
Contents
# frozen_string_literal: true module Auther # Manages encryption/decryption. class Cipher BYTE_DIVISOR = 2 def self.generate login, password secret = SecureRandom.hex key_length / BYTE_DIVISOR cipher = new secret {secret:, login: cipher.encrypt(login), password: cipher.encrypt(password)} end def self.key_length = ActiveSupport::MessageEncryptor.key_len def initialize secret @encryptor = ActiveSupport::MessageEncryptor.new secret end def encrypt(data) = encryptor.encrypt_and_sign data def decrypt(data) = encryptor.decrypt_and_verify data private attr_reader :encryptor end end
Version data entries
12 entries across 12 versions & 1 rubygems