lib/blind_index.rb in blind_index-2.0.1 vs lib/blind_index.rb in blind_index-2.0.2

- old
+ new

@@ -115,17 +115,17 @@ key = BlindIndex::KeyGenerator.new(master_key).index_key(table: table, bidx_attribute: bidx_attribute) key = key.unpack("H*").first if encode key end - def self.decode_key(key) + def self.decode_key(key, name: "Key") # decode hex key if key.encoding != Encoding::BINARY && key =~ /\A[0-9a-f]{64}\z/i key = [key].pack("H*") end - raise BlindIndex::Error, "Key must use binary encoding" if key.encoding != Encoding::BINARY - raise BlindIndex::Error, "Key must be 32 bytes" if key.bytesize != 32 + raise BlindIndex::Error, "#{name} must be 32 bytes (64 hex digits)" if key.bytesize != 32 + raise BlindIndex::Error, "#{name} must use binary encoding" if key.encoding != Encoding::BINARY key end def self.backfill(relation, columns: nil, batch_size: 1000)