←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

SHA-256 API?

!!!!!!!!!!ExclaimationMark's Photo !!!!!!!!!!ExclaimationMark 10 Aug 2014

I've heard of an SHA256 API floating around here. where is it?
Quote

theoriginalbit's Photo theoriginalbit 10 Aug 2014

The forum search is an amazing thing.
Edited by theoriginalbit, 10 August 2014 - 12:25 PM.
Reason for edit:: copied the wrong link
Quote

!!!!!!!!!!ExclaimationMark's Photo !!!!!!!!!!ExclaimationMark 10 Aug 2014

I saw that. still confused.
Quote

theoriginalbit's Photo theoriginalbit 10 Aug 2014

So if you saw it, why did you ask where the API was? :huh:

What is confusing about it?
Quote

TheOddByte's Photo TheOddByte 10 Aug 2014

If you looked through the code you would have found a function called sha256 at the bottom, it's easy to use
local text    = "Hello"
local hash  = sha256( text )

Now if you want to use this as an API you would have to remove the local before the function so it can be used
Like this
Now load it as you usually do with APIs
os.loadAPI( "hash" ) -- we're going to call the file hash here, change it to whatever you named it
print( hash.sha256( "Hello" ) )
Quote

!!!!!!!!!!ExclaimationMark's Photo !!!!!!!!!!ExclaimationMark 11 Aug 2014

Oh, and BTW, will it work on other Luas (e.g. OC Lua(5.2), Roblox Lua (5.1))
Quote

theoriginalbit's Photo theoriginalbit 11 Aug 2014

its a completely contained API, requiring nothing external, so yes, it should work. However the way you load it will differ.
Quote

!!!!!!!!!!ExclaimationMark's Photo !!!!!!!!!!ExclaimationMark 11 Aug 2014

 theoriginalbit, on 11 August 2014 - 01:17 AM, said:

its a completely contained API, requiring nothing external, so yes, it should work. However the way you load it will differ.
According to the thread it's supposed to be in the program, so... no need to load
Quote

theoriginalbit's Photo theoriginalbit 11 Aug 2014

it can be external it doesn't have to be defined in the program.
Edited by theoriginalbit, 11 August 2014 - 05:48 AM.
Quote