2019-10-09 00:06:06 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Checksummable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
2020-09-28 15:09:44 +00:00
|
|
|
def crc32(data)
|
|
|
|
Zlib.crc32(data)
|
|
|
|
end
|
|
|
|
|
2021-09-27 15:10:13 +00:00
|
|
|
def sha256_hexdigest(path)
|
2020-08-28 00:10:34 +00:00
|
|
|
::Digest::SHA256.file(path).hexdigest
|
2019-10-09 00:06:06 +00:00
|
|
|
end
|
2021-09-27 15:10:13 +00:00
|
|
|
|
|
|
|
def md5_hexdigest(path)
|
|
|
|
::Digest::MD5.file(path).hexdigest
|
|
|
|
end
|
2019-10-09 00:06:06 +00:00
|
|
|
end
|
|
|
|
end
|