Computing Chef checksums in Ruby
When dealing with remote files, Chef uses SHA-256 checksums to avoid redownloading files that haven’t changed. Since I haven’t found a Windows command line tool for computing SHA-256 checksums, I rolled my own in Ruby.
require 'digest'
path = ARGV[0]
if File.exists? path
puts Digest::SHA256.file(path).hexdigest
end
Usage looks like:
ruby ~/sha256.rb path/to/file
No help, no options, no error handling. I use it all the time.