Sha256: ad23bce80fc20f6921cb556ab223048dc058aea92dd4ad975ddc68f36b06dfda

Contents?: true

Size: 660 Bytes

Versions: 11

Compression:

Stored size: 660 Bytes

Contents

module Unidom::Common::Concerns::Sha512Digester

  extend ActiveSupport::Concern

  included do |includer|

    def digest(message, pepper: nil)
      self.class.digest message, pepper: pepper
    end

    def hex_digest(message, pepper: nil)
      self.class.hex_digest message, pepper: pepper
    end

  end

  module ClassMethods

    def digest(message, pepper: nil)
      message.present? ? Digest::SHA512.digest("#{message}_#{Rails.application.secrets[:secret_key_base]}_#{pepper}") : nil
    end

    def hex_digest(message, pepper: nil)
      message.present? ? Unidom::Common::Numeration.hex(digest(message, pepper: pepper)) : nil
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
unidom-common-1.9.1 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.8 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.7.2 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.7.1 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.7 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.6 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.5 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.4 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.3 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.2 app/models/unidom/common/concerns/sha512_digester.rb
unidom-common-1.1 app/models/unidom/common/concerns/sha512_digester.rb