2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Checksummable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
2021-01-03 14:25:43 +05:30
|
|
|
def crc32(data)
|
|
|
|
Zlib.crc32(data)
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
def sha256_hexdigest(path)
|
2020-11-24 15:15:51 +05:30
|
|
|
::Digest::SHA256.file(path).hexdigest
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
def md5_hexdigest(path)
|
|
|
|
::Digest::MD5.file(path).hexdigest
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
end
|