Sha256: f27f0af57b510a40f4c607403f55deec9e0c8fde7923c113d1a4648ea4e00627

Contents?: true

Size: 586 Bytes

Versions: 16

Compression:

Stored size: 586 Bytes

Contents

module Nyauth
  class Encryptor
    include Singleton

    cattr_writer :secret, :cipher, :digest
    self.cipher = 'aes-256-cbc'
    self.digest = 'SHA512'

    attr_reader :encryptor

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

    class << self
      def encrypt(message)
        instance.encryptor.encrypt_and_sign(message)
      end

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
nyauth-0.7.2 lib/nyauth/encryptor.rb
nyauth-0.7.1 lib/nyauth/encryptor.rb
nyauth-0.7.0 lib/nyauth/encryptor.rb
nyauth-0.6.2 lib/nyauth/encryptor.rb
nyauth-0.6.1 lib/nyauth/encryptor.rb
nyauth-0.6.0 lib/nyauth/encryptor.rb
nyauth-0.5.0 lib/nyauth/encryptor.rb
nyauth-0.4.0 lib/nyauth/encryptor.rb
nyauth-0.3.0 lib/nyauth/encryptor.rb
nyauth-0.2.8 lib/nyauth/encryptor.rb
nyauth-0.2.7 lib/nyauth/encryptor.rb
nyauth-0.2.6 lib/nyauth/encryptor.rb
nyauth-0.2.5 lib/nyauth/encryptor.rb
nyauth-0.2.4 lib/nyauth/encryptor.rb
nyauth-0.2.3 lib/nyauth/encryptor.rb
nyauth-0.2.2 lib/nyauth/encryptor.rb