r/RStudio • u/Kiss_It_Goodbyeee • 2d ago
Coding help md5sum hashes of file not matching
This should be straightforward, but am struggling to get this to work. I've tried the digest and openssl libraries and neither matches what I get on the commandline.
Obviously the first thing to get right was to ensure I wasn't just hashing the filename (d'oh!). With the digest function I used this:
digest(file(system.file("myfile")), "md5")Which concerningly returns a different result each time it runs.
With the openssl md5() function I ran:
md5(file(system.file("myfile")))Which at least is consistent, but only returns the serialised output and doesn't match the output I get on the commandline with md5sum (on macOS).
Help. How do I get an md5sum in R that matches what I get on the commandline? NB: I don't want to do a system call as this needs to be cross platform.
