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