ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 8th, 2003, 06:00 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
File hashing w/ vbscript

atm i'm developing a vbscript that runs on windows to go through the entire harddrive and for each file creates a hash .. however for each file i'm reading the entire file and then creating the hash using md5..

my main problem is it's a v. time consuming process.. I already knew this would be a long time but still. Is there any other way of doing a good hash of files.. i thought about reading parts of the files but that wouldnt be an option i guess coz it wouldnt be accurate anymore..

The code i'm using to create the hash

Code:
Function getHash(file)
  Dim content
  Wscript.echo file.path
  set readfile = ofsfilesys.OpenTextFile(file.path, 1, false)

  content = readfile.read(file.size)
  getHash = md5(content)
end function


any suggestions on speed performances would be appreciated (if possible)

Reply With Quote
  #2  
Old September 8th, 2003, 08:30 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
stupid me.. the reading of the files doesnt actually take really long.. compared to hashing it.. atm i'm using a vbscript built set of functions to create a hash.. i suppose using a dll to do the hashing would be quicker ?
maybe even let the dll read the file + make a hash ?

Reply With Quote
  #3  
Old September 9th, 2003, 03:34 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Using a DLL usually results in drastic speed increases, so that would definately be the way to go.
If you have the resources, write your app in C/C++ for better performance.

Reply With Quote
  #4  
Old September 9th, 2003, 06:46 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Quote:
Originally posted by stumpy
Using a DLL usually results in drastic speed increases, so that would definately be the way to go.
If you have the resources, write your app in C/C++ for better performance.
thx tho i just had a interview with the ppl administrating the srever it's gonna run on .. They're gonna change it and one of the demands of the tool i'm gonna make is no use of 3rd party dll's/components coz of security/stability. (which is a must for the server it's running on)

I'm currently using CRC checking to see if anything changed.. looks ok now and is quite fast as long as i seperate the files in small parts.

gonna create/run a script to see what sizes is best to use to check..

using c/c++ isnt possible.. they want it in vbscript :/

thx for help anyhow

Reply With Quote
  #5  
Old September 9th, 2003, 07:58 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Quote:
using c/c++ isnt possible.. they want it in vbscript :/
WTF?! WHY?! Why would a SA say something as stupid as this? Surely they realise that using a scripting language is not wise for such a CPU/memory intensive task.

Reply With Quote
  #6  
Old September 9th, 2003, 08:10 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Quote:
Originally posted by stumpy
WTF?! WHY?! Why would a SA say something as stupid as this? Surely they realise that using a scripting language is not wise for such a CPU/memory intensive task.


yeh it is.. but they're also thinking about upcoming support.. after this project i'm gone there and i wont be around .. according to him there wont be any1 else to take up the support for c++ or sth

not my choice.. :/

Reply With Quote
  #7  
Old September 9th, 2003, 08:20 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Quote:
Originally posted by Relax


yeh it is.. but they're also thinking about upcoming support.. after this project i'm gone there and i wont be around .. according to him there wont be any1 else to take up the support for c++ or sth

not my choice.. :/


lol i'm currently running a script to see what the shortest time possible to hash is for possible filesizes..

using crc checking for a 1.7mb file it takes bout 73 secs.. (unless i can get it faster) this is with the crc checking created in vbscript.. no dll's.. imagine 1 gig of this (only 1 gig) .. should take bout 12 hours avg (assuming there are all files of 1.7mb to check) all that
ofcourse there are gonna be filters coz not all files have to be checked(like doc files etc or log files)

Reply With Quote
  #8  
Old September 9th, 2003, 08:30 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
LOL

Reply With Quote
  #9  
Old September 9th, 2003, 08:39 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Quote:
Originally posted by stumpy
LOL


^^

i know lol...

i dont think there's any other way then using atleast some sort of dll to do it .. or perhaps some built-in method of windows 2k(which is the target OS to run on) ?

Reply With Quote
  #10  
Old September 9th, 2003, 08:51 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Explain to me why you'd want to create a hash for every file on a HDD? Is this something people do regularly?

Reply With Quote
  #11  
Old September 9th, 2003, 09:07 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
quite simple.. there's loads of servers here.. and they want to see what files changed ... to make a copy of each file is not wanted lol.. so each time there's a hash created for each file... then on a different date there's another check being made.. for each file another hash.. then all filehashes gets compared and thus knowing which files have changed

this is only part of the script i'm currently developing tho..

Reply With Quote
  #12  
Old September 9th, 2003, 09:10 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Reinventing the wheel

By default, NTFS stores a "date modified" file attribute

Reply With Quote
  #13  
Old September 9th, 2003, 09:22 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Re: Reinventing the wheel

Quote:
Originally posted by stumpy
By default, NTFS stores a "date modified" file attribute


yeah i know .. thought about that and so did they.. date modified can be altered.. so not reliable :/

Reply With Quote
  #14  
Old September 10th, 2003, 03:48 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
i cant seem to get the process going faster with pure vbscript..
i found out there's an api within windows to do hashing.. only problem is using it from vbscript.. it's not 3rd party so i hope they'll agree on using it..

i got no idea on how to use it yet tho.. it's not an activex dll and vbscript doesnt support api calls.. :/

is there a way to use rundll32.exe or sth and retrieve the return value the according function gives from the running dll ? so i'd use windows shell to run the dll's function..

Reply With Quote
  #15  
Old September 10th, 2003, 04:21 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
As i said before - you won't get any more juice out of a scripting language. They simply aren't designed for the kind of stuff you want to do. You have no control over threading, etc. C/C++ is the only sensible option for this task.

Reply With Quote
  #16  
Old October 28th, 2003, 03:00 AM
Relax Relax is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 43 Relax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
update for ppl with same problem..

i've been researching this problem for qutie a while(next to my current assignments) and i found that the only way of doing it with vbs/wsh would be by using either:

1) hashing algorithm written in vbscript itself.. which is really slow but works when you only need to hash a few files.. however doing a hash for all files on a comp isnt really feasable.

2) using a activeX component. Microsoft has an activex component based the on the cryptoAPI. it's called capicom .. there are loads of other activex components out there as well but ofcourse if you want to play it safe u can use capicom.

3) using c++/vb/etc to write a standalone application...

i'm using nr 3 for my current project coz the company i'm doing this for doesnt want any extra activeX components installed..

hope this might help other ppl searching in the future

Reply With Quote
  #17  
Old September 3rd, 2004, 03:14 AM
miksib miksib is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 miksib User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
vb md5 file hashing

I all,
i need to make file hashing in a vb6 application and in lotus notes.

I'd like to know if there's a smart way to realize this using the microsoft standard api as CAPICOM.

I need to compute the md5 hash simply as you made in your code with

content = readfile.read(file.size)
getHash = md5(content)

Any good idea? Where can i found the md5 command that you've used in your code ?
thank you very much.

Mik

Quote:
Originally Posted by Relax
atm i'm developing a vbscript that runs on windows to go through the entire harddrive and for each file creates a hash .. however for each file i'm reading the entire file and then creating the hash using md5..

my main problem is it's a v. time consuming process.. I already knew this would be a long time but still. Is there any other way of doing a good hash of files.. i thought about reading parts of the files but that wouldnt be an option i guess coz it wouldnt be accurate anymore..

The code i'm using to create the hash

Code:
 Function getHash(file)
   Dim content
   Wscript.echo file.path
   set readfile = ofsfilesys.OpenTextFile(file.path, 1, false)
 
   content = readfile.read(file.size)
   getHash = md5(content)
 end function
 


any suggestions on speed performances would be appreciated (if possible)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > File hashing w/ vbscript


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap