Hello there, I need help.
I'm searching for checksum funtionality to use with ruby,
it seems that I have all I need with digest/md5 but I can't find any
documentation about how to use it (searched on ruby-doc and RAA)
Can someone help me?
To set a baseline, I used md5sum to checksum "hello there\n"
[mike@won mike]$ echo "hello there" > test.txt
[mike@won mike]$ md5sum test.txt
2d01d5d9c24034d54fe4fba0ede5182d test.txt
I used irb and some guesswork to figure out its methods, the guess being
that Digest::MD5 was the right package:
[mike@ratdog mike]$ irb=> ["<<", "digest", "hexdigest", "update"]
So now I see what I can do, let's try updating the empty digest, pick
one of update or << ...
=> 2d01d5d9c24034d54fe4fba0ede5182d
Looks familiar
=> "2d01d5d9c24034d54fe4fba0ede5182d"
So you can use ruby's reflection to get a crude handle on things, but
documentation would say whether you can add content in the constructor:
=> 2d01d5d9c24034d54fe4fba0ede5182d
It seems that you can initialise it with any String, so
f087dea38c54a8b40d3dbc8b0becfb4c
=> nil
or
=> "f087dea38c54a8b40d3dbc8b0becfb4c"
are reasonable ways to checksum a file (at least on linux where I don't
care about binary mkode...)
Hope this helps,
Mike