summaryrefslogtreecommitdiff
path: root/app/models/concerns/checksummable.rb
blob: 9812c62fcc4d65574345850df95ad2909da5cbdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module Checksummable
  extend ActiveSupport::Concern

  class_methods do
    def crc32(data)
      Zlib.crc32(data)
    end

    def sha256_hexdigest(path)
      ::Digest::SHA256.file(path).hexdigest
    end

    def md5_hexdigest(path)
      ::Digest::MD5.file(path).hexdigest
    end
  end
end