I wanna get the md5 checksums of files from within Ruby code.
I realize I can simply loop, read chunks of the file and
update an MD5 object but that would be very much slower than
using an external MD5 checksum program and I have very many
files to check.
Is there some trick to speed this up or should we consider adding
a checksum_of_file method to Digest?
In message “Quickest way to get md5 of a file?” on 02/12/22, coma_killen@fastmail.fm coma_killen@fastmail.fm writes:
I wanna get the md5 checksums of files from within Ruby code.
I realize I can simply loop, read chunks of the file and
update an MD5 object but that would be very much slower than
using an external MD5 checksum program and I have very many
files to check.
Is there some trick to speed this up or should we consider adding
a checksum_of_file method to Digest?
This doesn’t work on Windows 2K, Ruby 1.6.7 or 1.7.3-7
It says that ‘f’ is not a valid file.
File.read(f) doesn’t work on 1.6.7 (use File.new(f).read but it does work on
1.7.3-7)
You can escape the vertical line using caret like this.
C:>ruby -r digest/md5 -e ‘ARGV.each{^|f^| … }’ *
However, I couldn’t find any documents for this special
usage of the caret on Windows. I found this useful tips
by trial and error. Does anyone know where the official
document is?
This doesn’t work on Windows 2K, Ruby 1.6.7 or 1.7.3-7
It says that ‘f’ is not a valid file.
File.read(f) doesn’t work on 1.6.7 (use File.new(f).read but it does work on
1.7.3-7)