you can

subkeys = {}
4.times do |i|
subkeys[:"key#{i}"] = OpenSSL::Digest::SHA256.new.digest("#{i} #{key}")
end

-- 
Posted via http://www.ruby-forum.com/.