Sha256: a3a06461def35790c8524c8bc499c2235f6bc575193e06324a7cc6eb581cd88e
Contents?: true
Size: 651 Bytes
Versions: 4
Compression:
Stored size: 651 Bytes
Contents
# frozen_string_literal: true module Hashtastic class EthereumSHA3 class << self def call(*values) values = values.flatten.map do |value| if value.is_a?(String) if value[0..1] == '0x' value[2..-1] else value.unpack('H*') end elsif value.is_a?(Numeric) value.to_s(16).rjust(64, '0') else '' end end "0x#{Digest::SHA3.hexdigest(packed_values(values), 256)}" end def packed_values(values) [values.join].pack('H*') end alias digest call end end end
Version data entries
4 entries across 4 versions & 1 rubygems