Hold on I'll make one 3x faster
That's a good challenge, if you can make a faster version that'd be fantastic!
T[48] is useless, just delete that I was testing if filling the last 48 characters of W make it function the same, it does.
W[64] doesn't have to be that long, it can have a length of 16 and still function the same, but I made it 64 to avoid having to check for "SUBSCRIPT OUT OF RANGE" errors.
Lots of implementations do that differently. JavaScript uses a length of 16 because indexing negative numbers does not error, just gives undefined (which turns into 0 when applying math), which is perfect behavior and allows JavaScript to run this algorithm really fast because of no bound checking.
K is full of 64 constants (prime numbers), and I generate those every time it's ran, now that I think of it, that's most certainly what's making it slow...
In the previous version, if a block in hex starts with zeros, they would be chopped off, returning incorrect less-than-64-character hashes, that's fixed now. Also, sorry 12Me21 but I made lots of performance improvements...
There were quite a bit of things slowing it down
I'm getting around 250 per second, with input/output as arrays.
Damn
Make sure you're timing things right, that'd make each hash around 4 milliseconds, mine hashes at 9-10 milliseconds each
I always thought strings and arrays were the exact same thing in SB
After moving some of the rotate and shift operations inline, I'm getting around 380 hashes per second.
The most annoying part is how SHA uses pretty much ALL right shifts and right rotates, while SB doesn't have an unsigned right shift operator.
Ok, after inlining all the shifts and rotates, the speed is 600 hashes per second
You only have to do it once since K is never modified.
Replying to:12Me21Ok, after inlining all the shifts and rotates, the speed is 600 hashes per second
I like how Chrome thinks itโs all in Danish.
Replying to:12Me21Ok, after inlining all the shifts and rotates, the speed is 600 hashes per second
12Me21 you should submit it!
Replying to:12Me21Ok, after inlining all the shifts and rotates, the speed is 600 hashes per second
Lol Chrome bugged out for me too.
That's a nice program 12.
There's already been a faster version for almost a year