Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.digest.crc, std.digest.digest, std.stdio;
- string computeCrc32_A(string path)
- {
- CRC32 crc;
- auto file = File(path, "rb");
- foreach (ubyte[] data; chunks(file, 4096)) {
- crc.put(data);
- }
- return crcHexString(crc.finish());
- }
- string computeCrc32_B(string path)
- {
- CRC32 crc;
- auto file = File(path, "rb");
- foreach (ubyte[] data; chunks(file, 4096)) {
- crc.put(data);
- }
- return toHexString!(Order.decreasing)(crc.finish()); // return nothing or garbage
- }
- void main()
- {
- writeln(computeCrc32_A("file.txt")); // OK
- writeln(computeCrc32_B("file.txt")); // write nothing or garbage
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement