FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Help] problem with hashing(Digest), threading & DWT

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
Fileburner



Joined: 28 Apr 2009
Posts: 11

PostPosted: Mon Sep 14, 2009 2:10 pm    Post subject: [Help] problem with hashing(Digest), threading & DWT Reply with quote

Hello everyone,

I am new to D programming language, and I am having some problems Razz
I wanted to ask in the right forum "Tango" and "DWT" but I can't find tango forum and DWT forum is closed Sad

I hope you don't mind if I ask for help in this forum.

ok here is my problemS

1 - I am trying to hash(Digest) a file using Tango's predefined digests. here is the code I used
Code:
   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
Code:
   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

2 - is a problem I have with threading and DWT I would like to put a progressBar in my Form(Shell) which progresses according to processed file data, in other words while hashing the file progress the progressBar until the file is done hashing. can anyone please guide me how to do it, because I am new at threading Razz

thank you.

Fileburner.
Back to top
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Tue Sep 15, 2009 2:33 am    Post subject: Reply with quote

Tango's forum is located on the Tango website: http://www.dsource.org/projects/tango/forums . For DWT use the irc channel dwt on freenode or the DWT newsgroup: http://www.digitalmars.com/NewsGroup.html . About the DWT problem, try and see if you can find the problem in one of the SWT snippets: http://www.eclipse.org/swt/snippets/ . Some of them are ported to D: http://www.dsource.org/projects/dwt-samples/browser
Back to top
View user's profile Send private message
Fileburner



Joined: 28 Apr 2009
Posts: 11

PostPosted: Tue Sep 15, 2009 7:34 am    Post subject: Reply with quote

thank you for your reply Smile, I am gonna take a look a these links
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group