RE: [JAVA] MD5 Bruteforcer [Highly efficient] 11-05-2012, 05:53 AM
#5
(11-04-2012, 04:25 PM)Frooxius Wrote: Why do you think that it's highly efficient?
This isn't very efficient, it contains a lot of method calls, constant allocations and deallocations, unnecessary copying of data around, so I wonder what are you basing the "highly efficient" claim on? All that is going to show on the performance especially if you feed it a hash of something that has more words, in fact, did you try feeding it a hash of a 20 character word and seeing how long it takes to find a match? There's still a long way before you can call this efficient. Also using C might help up to speed up things a lot, especially if you use the simplest Cstrings, instead of some wrapper with a bunch of functions.
Secondly you don't have to type out all the characters as you do in the code for the ar[] array of characters. Look at the ASCII table and you'll see that the characters are also grouped nicely, so you can simply use a range of character indexes, instead of typing them all out, it might be even faster based on conditions (it compares one variable to a predetermined value with the code, instead of fetching data from the memory which might take longer). Like this for example:
Code:if(ch >= 'a' && ch <= 'z')
Or you can populate that array with the code, using the trick I've shown above.
Additionally, don't return the answer via a function side effect, it's not a nice OOP practice and makes it harder to take the function and put it somewhere else. In fact, returning true or false with the generate function is completely redundant. Return the string instead and in case no match is found, return an empty string (or null), which will indicate that no match was found. Easy as that.
Lastly, I would like to clarify the difference between encryption and hash function. Hashing is not encryption and therefore decrypting a hash doesn't make any sense, because it's not encrypted data.
Hash transforms the data one way, into a fixed width string, basically generating unique foot-print of the data that was used to create it, but doesn't store the original data. Encryption only transforms a way the data is expressed in some way, so it's unreadable to anyone who doesn't know a way to transform it back (decrypt it), but all of the data are still there, so they can be decrypted.
Ok... Thanks for the suggestions on making my programs more efficient... Will remember them next time...
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)