Constants
SUPPORTED_ALGORITHMS | = | [:sha1, :sha256, :sha384, :sha512, :md5, :crc32] | ||
SUPPORTED_FORMATS | = | [:none, :hex, :base64] |
Public Class methods
new(algorithm, format:)
[show source]
# File lib/shrine/plugins/signature.rb 58 def initialize(algorithm, format:) 59 raise Error, "unknown hash algorithm #{algorithm.inspect}, supported algorithms are: #{SUPPORTED_ALGORITHMS.join(",")}" unless SUPPORTED_ALGORITHMS.include?(algorithm) 60 raise Error, "unknown hash format #{format.inspect}, supported formats are: #{SUPPORTED_FORMATS.join(",")}" unless SUPPORTED_FORMATS.include?(format) 61 62 @algorithm = algorithm 63 @format = format 64 end
Public Instance methods
call(io)
[show source]
# File lib/shrine/plugins/signature.rb 66 def call(io) 67 hash = send(:"calculate_#{algorithm}", io) 68 send(:"encode_#{format}", hash) 69 end