Blockland Forums > Modification Help
[Library] SHA-256
(1/5) > >>
Xalos:
In light of a SHA-1 collision being found in practice, Blockland no longer has any default functions capable of providing even the slightest glimmer of cryptographic security.  So I decided to write SHA-256 in TorqueScript.

This library was written using pseudocode from the Wikipedia page on SHA-2, an addition function by Port, and test vectors for several SHA variants from DI Management.

The function in this library operates much in the same way as the default sha1 function, taking a string and returning the hash of that string in hexadecimal.  It should work on any string that does not overflow the TorqueScript string buffer, but as it is written in TorqueScript it may hang Blockland for noticeable periods of time for very long strings.

Please note that unless you are writing code where the cryptographic properties of SHA-256 are important, you should probably stick to using the default sha1 function, which is much faster than any hashing function written in TorqueScript.


Benchmark comparisons:
Running sha1("") 999999 times: 2400 ms, or ~2.4 µs per call
Running sha256("") 9999 times: 124736 ms, or ~12.5 ms per call
FelipeO_O_:
Cool can it decode too?
Gytyyhgfffff:
xalos your next task is to make a sha256 decoder in torque script
mctwist:

--- Quote from: FelipeO_O_ on March 19, 2017, 01:56:01 PM ---Cool can it decode too?

--- End quote ---

--- Quote from: Gytyyhgfffff on March 19, 2017, 02:10:31 PM ---xalos your next task is to make a sha256 decoder in torque script

--- End quote ---

Why not invent time travel while he's at it?


On topic: A bunch of scripters recommend using global variables instead of local variables as they are significantly faster (Up to 1000 times if I remember correctly).
Conan:

--- Quote from: mctwist on March 19, 2017, 03:36:08 PM ---On topic: A bunch of scripters recommend using global variables instead of local variables as they are significantly faster (Up to 1000 times if I remember correctly).

--- End quote ---
can confirm. if it wasn't for this property zeblotes' new duplicator wouldnt really be possible.
Navigation
Message Index
Next page

Go to full version