This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DiamondTNT's profile picture

Hashing 44KB file with SHA256

Started by DiamondTNT, 07 June 2014 - 12:47 AM
DiamondTNT #1
Posted 07 June 2014 - 02:47 AM
When I install my "OS" onto a computer using a floppy, I use GravityScore's implementation of SHA256(here) on all of my main system(non-user) files(as a checksum). One of them is a hash of AES256, found here. The computer screen goes black after about 10 seconds of attempting to calculate this. If an error is thrown, it completes successfully, otherwise it goes black. Also, there is a random salt applied before the hash every time you reinstall the OS, so this cannot be precalculated. Note: The 44 KB file is the AES256 file.
Edited on 07 June 2014 - 12:48 AM
Bomb Bloke #2
Posted 07 June 2014 - 03:39 AM
When a computer/turtle starts running code, ComputerCraft starts a ten second timer. If that code doesn't yield before that timer ends then ComputerCraft crashes that computer. After each yield, processing continues with a new time limit.

The reason why is that running your code chews up valuable server processing power, and so it shouldn't be able to monopolise it. In fact, only ONE CC device can run code at a time: While one is doing something, none of the others can do anything until it yields.

Whether or not it takes more then ten seconds for your code to execute has a lot to do with the power of the Minecraft server it's running on, and how often you allow your code to yield. Pulling events (eg getting typed characters) or sleeping triggers a yield, and many commands (eg turtle movements or getting text input from the user) have to pull events to work anyway.

If you throw something like this into where ever the main processing loop is, it should be able to avoid the yield-timer-shutdown without slowing things down too much:

os.queueEvent("moo")
os.pullEvent()
Edited on 07 June 2014 - 01:39 AM
DiamondTNT #3
Posted 07 June 2014 - 03:44 AM
Thx, so during the hashing I should queue and pull an event to avoid the crash?
Bomb Bloke #4
Posted 07 June 2014 - 03:55 AM
Yep.
Lua.is.the.best #5
Posted 09 June 2014 - 05:53 AM
Or just use coroutine.yield.