(#9983) Checksum files in binary mode
Previously, we were opening files in text mode when calculating file
checksums. On Windows, '\r\n' characters are automatically translated
to '\n', which corrupts the resulting checksum.
This commit ensures we open files in binary mode, similar to what
Digest::MD5.file(path).hexdigest does. Binary mode is a noop on Unix.
Similarly, Puppet::Type::File#write was writing the file content in
text mode, which was later validated using the checksum code, now
reading in binary mode. So Puppet::Type::File was changed to use
binary mode as well.
Also, some of the tests were writing files in text mode, but
checksumming them in binary mode, and obviously failing. Changed the
spec tests to write in binary mode also.