? Fast SHA-256 ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Fast SHA-256

Submitted
Updated
Author
Simeon
Public Key
2R5EN28V
Min. Compat.
All
Version
2.1
Size
2.8KB
Rating
7 votes
Description This is a hashing algorithm that can take an input of any length and return a unique 64-character-output in hexadecimal (256 bits). The great thing about this is the feature called the Avalanche Effect, where you can calculate the hash of a huge file of any size (gigabytes, terabytes in size), then change a single bit and recalculate that hash, now both hashes will be entirely different hashes with around half of the bits flipped. You can probably imagine how many uses this has in cryptography. Using the fastest computer in the world, it would take roughly ten times the age of the universe to reverse engineer one of these hashes. So if you're going to have a password system (or something similar), then hash the password and compare it to the hash of what the user types. This will make the password almost guaranteed impossible to crack. That's how programmers work with passwords. I'd love to see somebody make a bitcoin wallet generator with this! Instructions It runs an average of 106 (previously 71) hashes per second on the New 3DS. Usage is straightforwardPRINT SHA256("Hello World")Prints out A591A6D4 0BF42040 4A011733 CFB7B190 D62C65BF 0BCDA32B 57B277D9 AD9F146E
Categories
Keywords
21 Comment(s) Shelly Shelly 106 on New 3ds? Fast? Do you think that scrypt might utilize the 3ds hardware more efficiently, to yield more coins? DrZog DrZog Even running in optimized assembly, the 3ds is very inadequate for mining bitcoins. Even PCs with good GPUs can barely make a dent in bitcoins these days and they're 1000s of times faster than the 3ds. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Unless you get really really lucky, so technically its still possible to become rich from connecting this to the internet... you just have to be unimaginably lucky, lol But putting mining aside, considering that a typical application will only need to hash a few times, it's security comes in handy. It's not as much about speed for most situations. The fact that it's implemented is what matters. Shelly Shelly Well I was just saying that the 3ds might have a better price/performance ratio since the Dogecoin network (and other scrypt networks) aren't flooded with asics. amihart amihart This is really cool! Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Thanks! 12Me21 12Me21 Admin OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest Ok, after inlining all the shifts and rotates, the speed is 600 hashes per second Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Nu uh 12Me21 12Me21 Admin OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest http://12me21.github.io/sbhighlight3/#Ttextarea%3BP%3B7Nthh~Cbutton Warrior Warrior Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies I like how Chrome thinks it’s all in Danish. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 12Me21 you should submit it! spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Lol Chrome bugged out for me too. That's a nice program 12. 12Me21 12Me21 Admin OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest I'm getting around 250 per second, with input/output as arrays. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 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 12Me21 12Me21 Admin OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest After moving some of the rotate and shift operations inline, I'm getting around 380 hashes per second. 12Me21 12Me21 Admin OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest 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. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 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 12Me21 12Me21 Admin OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest Hold on I'll make one 3x faster Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 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... snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Shove the primes into an inline DATA block inside the function and copy them in. COPY K,@PRIMES 12Me21 12Me21 Admin OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest You only have to do it once since K is never modified.