Followers 0

SHA1 hashing of file

7 posts in this topic

i am creating a tool like maketorrent to create a torrent

i saw in the search that SHA1 hashing support can be added through an UDF (?) but i dont see any where how i can create sha1 hashes from parts of files (this is what happens when creating a torrent, you has pieces of xxkb at a time (the amount is definable)

so anyone who has a good tip for me?

nobody

Share on other sites

I'm don't really know much about bittorrents, but I may be able to help you if you can describe what it does. Need to know more about it.

Share on other sites

#4 ·  Posted (edited)

JSThePatriot has a rather good md5.dll kicking around the forum, but sadly no SHA1 built in yet (any opportunity to drop a hint!) but there are other libraries out there that will more or less do what you want. It depends where you want the result to go, I mean physically. It's something I'm currently casually looking into myself, hence the hint, above.

Yesterday I came across this handy looking dll...

http://www.paehl.de/english.php (HASHES DLL 1.01)

And called it like this...

$foo = DllCall("hashes.dll", "str", "testit", "str", "foo.txt", "str", "SHA1", "str", "foo.txt.sha1") and it creates the SHA1 of the file "foo.txt", and drops it into a file called "foo.txt.sha1", along with a copyright notice. If you leave the last string as "", it dumps it into the console, but I haven't figured out a way to capture that and use it in my script, and after seeing the copyright notice, I probably won't bother. It looks doable, and that would get your SHA1, and fast. ReadConsole maybe. dunno. What I'd like to do is just grab the C++ source for sha1 (which is freely available) and compile it along side the MD5 algorythm in my existing hashing dll, but my C skills are fairly limited, and my last two attempts ended in frustration. What I'd really like is for JS to do it! There's bound to be a SHA1 UDF somewhere (surely!), but it will likely be very slow compared to handing the task off to a compiled dll. I guess for torrent creation blazing speed is not vital (it is for my application). If you can get the SHA1 (that dll also does every other hash in the known universe) cleanly out of that dll, then let me know! -mu ps.. If there isn't a SHA1 UDF kicking around, the code looks like it wouldn't be too challenging to port to AutoIt, and you might want to do that.  no need: http://www.autoitscript.com/forum/index.ph...55&hl=SHA1++UDF You especially want to look at this... http://www.autoitscript.com/forum/index.ph...22&hl=SHA1++UDF [/edit] Edited by mr.underperson Share this post Link to post Share on other sites I'm don't really know much about bittorrents, but I may be able to help you if you can describe what it does. Need to know more about it. bittorrent create a file with some info (most of it i can create without a problem) but the tricky part is the fact that sha1 hashing.. what does it do: piece size = 200kb u have 3 files of 450KB what does it need to do: 1 read from file 1 200KB then create a sha1 hash from that 2 read another 200KB and create sha1 hash 3 read from file 1 50KB and from file 2 you read 150 (to total up to 200KB) and create sha1 hash continue this until you have done all files. Share this post Link to post Share on other sites See my previous post. follow the link, download the plugin. then do... $string = "my string here"
$hash_dll = "C:\Path\to\my_hash.dll" ; or whatever you call it$HashPlug = PluginOpen($hash_dll)$foo = StringHash($string, 2)$foo is your SHA1 hash.

Problem solved.

-mu