Heads up: This description was created by AI and might not be 100% accurate.

md5sum.rb

This Ruby code snippet demonstrates the use of the Digest::MD5 library to calculate the MD5 hash of a string and a file. The first example calculates the MD5 hash of the string “ruby”, resulting in the hexadecimal representation “58e53d1324eef6265fdb97b08ed9aadf”. The second example calculates and prints the MD5 hash of the file ‘input/digest/md5sum.rb’, producing the hexadecimal hash “b9e992f67fcc4e238d9964a07aba6dd7”.

Ruby code snippet

require 'digest/md5'
#=> true

Digest::MD5.hexdigest("ruby")
#=> "58e53d1324eef6265fdb97b08ed9aadf"

Digest::MD5.file('input/digest/md5sum.rb').to_s
#=> "b9e992f67fcc4e238d9964a07aba6dd7"

Executed with Ruby 3.4.5.