<commit_before>##
# SHA-384 Digester 基于 SHA-384 算法的摘要逻辑关注点。

module Unidom::Common::Concerns::Sha384Digester

  extend ActiveSupport::Concern

  included do |includer|

    ##
    # 对明文 message 进行 SHA-384 摘要， pepper 是用于增加混乱的内容。如：
    # class SomeModel
    #   include Unidom::Common::Concerns::Sha384Digester
    #   def some_method(param_1)
    #     digest param_1
    #     # 或者
    #     digest param_1, pepper: 'my_pepper'
    #   end
    # end
    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::SHA384.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<commit_msg>1, Improve the SHA-384 Digester for the document.<commit_after>##
# SHA-384 Digester 基于 SHA-384 算法的摘要逻辑关注点。

module Unidom::Common::Concerns::Sha384Digester

  extend ActiveSupport::Concern

  included do |includer|

    ##
    # 对明文 message 进行 SHA-384 摘要， pepper 是用于增加混乱的内容。如：
    # class SomeModel
    #   include Unidom::Common::Concerns::Sha384Digester
    #   def some_method(param_1)
    #     digest param_1
    #     # 或者
    #     digest param_1, pepper: 'my_pepper'
    #   end
    # end
    def digest(message, pepper: nil)
      self.class.digest message, pepper: pepper
    end

    ##
    # 对明文 message 进行 SHA-384 摘要，并以16进制的形式返回， pepper 是用于增加混乱的内容。如：
    # class SomeModel
    #   include Unidom::Common::Concerns::Sha384Digester
    #   def some_method(param_1)
    #     hex_digest param_1
    #     # 或者
    #     hex_digest param_1, pepper: 'my_pepper'
    #   end
    # 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::SHA384.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
{'fraction_non_alphanumeric': 0.10749047820567076, 'fraction_numerical': 0.024121878967414304, 'mean_word_length': 3.075862068965517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1081151', 'n_tokens_mistral': 942, 'n_tokens_neox': 881, 'n_words': 180}