Module: Unidom::Common::Concerns::Sha1Digester::ClassMethods
- Defined in:
- app/models/unidom/common/concerns/sha1_digester.rb
Instance Method Summary collapse
-
#digest(message, pepper: nil) ⇒ Object
对明文 message 进行 SHA-1 摘要, pepper 是用于增加混乱的内容。如: class SomeModel include Unidom::Common::Concerns::Sha1Digester def self.some_method(param_1) digest param_1 # 或者 digest param_1, pepper: ‘my_pepper’ end end.
-
#hex_digest(message, pepper: nil) ⇒ Object
对明文 message 进行 SHA-1 摘要,并以16进制的形式返回, pepper 是用于增加混乱的内容。如: class SomeModel include Unidom::Common::Concerns::Sha1Digester def self.some_method(param_1) hex_digest param_1 # 或者 hex_digest param_1, pepper: ‘my_pepper’ end end.
Instance Method Details
#digest(message, pepper: nil) ⇒ Object
52 53 54 |
# File 'app/models/unidom/common/concerns/sha1_digester.rb', line 52 def digest(, pepper: nil) .present? ? Digest::SHA1.digest("#{}_#{Rails.application.secrets[:secret_key_base]}_#{pepper}") : nil end |
#hex_digest(message, pepper: nil) ⇒ Object
66 67 68 |
# File 'app/models/unidom/common/concerns/sha1_digester.rb', line 66 def hex_digest(, pepper: nil) .present? ? Unidom::Common::Numeration.hex(digest(, pepper: pepper)) : nil end |