Sha256: e1d67356d566b9f3487785fb6b65aa365cc7702a16ad4d349e9a9b70e4f158a5
Contents?: true
Size: 732 Bytes
Versions: 1
Compression:
Stored size: 732 Bytes
Contents
## # SHA-256 Digester 基于 SHA-256 算法的摘要逻辑关注点。 module Unidom::Common::Concerns::Sha256Digester 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::SHA256.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-common-1.9.2 | app/models/unidom/common/concerns/sha256_digester.rb |