Stewart Gordon schrieb:
The .ptr is necessary, but the cast(uint) isn't. Even if a change of type were necessary, just 1U would do. (U is a suffix meaning unsigned. There's also L meaning long.)

Stewart.

Thank Stewart.

As the std.md5-example is not working with "unicode" file names (fopen...) I rewrote the "MDFile" function and use "file.readBlock" instead now. Maybe the std.md5 example should be changed to use a "file.read" or "file.readBlock".

Here is my code (I've checkedthe file exists and is readable before):

string MD5File(string fileName) {
        
        File file = new File;
        MD5_CTX context;
        int len;
        ubyte[4 * 1024] buffer;
        ubyte digest[16];

        file.open(fileName, FileMode.In);       
        context.start();
        while ((len = file.readBlock(buffer.ptr, buffer.sizeof)) != 0)
                context.update(buffer[0 .. len]);
        context.finish(digest);
        file.close();
        
        string MD5Sum = (digestToString(digest));
        return MD5Sum;
        
}

Regards
notna

Reply via email to