Forum Navigation
[Help] hashing(Digest) problem
Posted: 09/15/09 15:59:34 Modified: 09/15/09 16:09:24Hello everyone,
I am new to D programming language, and I am having some problems :P
ok here is my problem
I am trying to hash(Digest) a file using Tango's predefined digests. here is the code I used
public void hashTestMethod(char[] filePath){ Md5 d = new Md5(); auto f = new FileConduit(filePath); ubyte[] buffer = new ubyte[2048*1024]; int i = f.read(buffer); while (i!=f.Eof){ d.update(buffer); i = f.read(buffer); } txtResult.setText(d.hexDigest()); f.close(); }using this code I get a wrong result, but if I use the followig code I get the right result
public void hashTestMethod(char[] filePath){ Md5 d = new Md5(); auto f = new FileConduit(filePath); d.update(f.load()); txtResult.setText(d.hexDigest()); f.close(); }but the previous code loads the whole file to the memory which is not a good Idea
can anyone guide me to a proper way using buffers also if anyone can point me to a threading tutorial in D (how data is shared between threads, concurency management ....)
thank you.
Fileburner.