Digest::MD5 in array-loop gives same hash for all files

Hi there,

this is ruby 2.2.3 on Mac.

i have an array with files ( paths ).

all files are clearly different in their content.

if i iterate like so:

images.each do |image|
hash = Digest::MD5.file(image).hexdigest
puts "#{hash} #{image} "
end

i get this output:

d41d8cd98f00b204e9800998ecf8427e
/Users/develop/Desktop/image_import/testnnn-450.jpg
d41d8cd98f00b204e9800998ecf8427e
/Users/develop/Desktop/image_import/testnnn-451.jpg
d41d8cd98f00b204e9800998ecf8427e
/Users/develop/Desktop/image_import/testnnn-452.jpg
d41d8cd98f00b204e9800998ecf8427e
/Users/develop/Desktop/image_import/testnnn-453.jpg
… some more hundreds…

for single files the hash seems correct.
so Digest::MD5.file seems to cache?? or what am i doing wrong??

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs