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