I cant encode files

Hello all, help me please. I have files and i need encode them in SHA3-256. I done it with this gem GitHub - johanns/sha3: SHA3 for Ruby is a XKCP based native (C) binding to SHA3 (FIPS 202) cryptographic hashing algorithm and i check myself with this SHA3-256 File Checksum Online . First file was encode right, but others — no. What i did wrong?

my code:

require ‘sha3’

s = SHA3::Digest.new(:sha256)

path = ‘files2’

array = Array.new

i=0

papka = Array.new

papka = Dir.entries(path)

papka.each do |filename|

if filename == "." || filename == ".."

next

end

file = File.open("#{path}/#{filename}", 'r')

puts filename

s.update ''

array[i] = s.file(file).hexdigest

puts array[i]

file.close

i += 1

end

I think you should not reuse the SHA3-Object

require ‘sha3’

path = ‘files2’
the_array = Dir.entries(path).map do |f|_
   next if ["..","."].include? f
   file = File.open("#{path}/#{f}", 'r')
   puts f
   s = SHA3::Digest.new(:sha256)
   s.update ''
   a= s.file(file).hexdigest
   puts a
   file.close
   a
end