This topic contains 1 reply, has 2 voices, and was last updated by SourcecodeDeleted 1 month, 1 week ago.
- AuthorPosts
- January 25, 2021 at 2:18 am #355323
A few weeks ago I was curious to know how fast the hashcat tool was compared to a code I wrote in Java.
Result:
My Java code: 15 H/s
Hashcat: 360 H/s
I was impressed with the speed gain, in a process that would take 24 hours with my Java code, in the hashcat it would only take 1 hour. As I have other Java projects that also perform a lot of calculations and have a long execution time, I would like to know a way to better the speed of my processes like this.
Edit: I did the test and while in Java the code runs in 16 sec, in C the same code takes 56 seconds.
It seems to me that changing the language to C is not a better choice.
Test algorithm used: make 40 billion logical comparisons (if).
- January 25, 2021 at 2:18 am #355324
SourcecodeDeletedJava is a memory whore.
Hashcat can use the GPU too.
- January 25, 2021 at 2:18 am #355325
atsjuMaybe just because it’s coded in C and not java. Some high level languages are just very slow…
- January 25, 2021 at 2:18 am #355326
SingleEscape6For your edit, I believe it’s because you don’t master the C language as you master Java (probably) because structurally C is created to be largely faster than any other language, because running at a very low level (and yes I know that C preceded all of them, it’s a figure of speech).
It’s not necessarily a bad or a good thing, it’s just as it’s but for hashcat, it’s written in C and I believe it’s good C, well written and very optimized.
Also I just saw on their website then need a GPU so I believe they do their calculation on GPU not CPU, maybe you could try to recode your stuff for GPU and see if there is any difference (there should be, if there is no difference, your code have a problem)
- January 25, 2021 at 2:18 am #355327
thisdotstateHashcat is written in C.
Simply put, if speed is your top priority then don’t write these programs in Java.
Java has a lot of unnecessary overhead. It doesn’t lend itself to this type of application where you are doing lots of raw math.
- January 25, 2021 at 2:18 am #355328
Straight-Theory1991Hashcat uses the GPU and it’s written in C
- January 25, 2021 at 2:18 am #355329
tinycrazyfish>Java being slow is a myth?
Yes it is a myth. You can write very fast code in Java. Optimization is a difficult task, be in c, java or any other languages. It’s true that’s optimized c code will always be faster than optimized Java. However, Java can be very close (except with heavy memory load/management, Java’s garbage collector will always be slower than manual and optimized memory management)
Hashcat is fast because it uses the GPU. It also makes assumptions/approximation to run faster. E.g. hashcat optimized code (-O), the length of the password to bruteforce is limited in length. Another example to illustrate may be the inverse square root: the standard implementation would be 1/sqrt(x), but look at the fast inverse square root https://en.m.wikipedia.org/wiki/Fast_inverse_square_root. It was initially coded for Quake 3, and it is way faster than the naive implementation, but it is an approximation, but sufficient for Quake 3’s use.
Java has bindings to opencl, so you may be able to write code targeting the GPU ,too. I never tried it though, no idea how it performs.
Switch to c? …. Don’t, the learning curve is high (pointers and memory management) and your Java habits will handicap you. (I make the assumption you are a hardcore Java developer 🙂)
- January 25, 2021 at 2:18 am #355330
aediniusCan you share your code for comparison?
- January 25, 2021 at 2:18 am #355331
djm406_I’d put money on Java code that uses the graphics card is roughly 10x faster then the fastest C code that just uses the cpu.
When used properly graphics cards can do things a hundred times faster (at least) over the CPU.
- AuthorPosts
You must be logged in to reply to this topic.
Comments