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

SHA-256 API?

Started by !!!!!!!!!!ExclaimationMark, 10 August 2014 - 06:37 AM
!!!!!!!!!!ExclaimationMark #1
Posted 10 August 2014 - 08:37 AM
I've heard of an SHA256 API floating around here. where is it?
theoriginalbit #2
Posted 10 August 2014 - 09:21 AM
The forum search is an amazing thing.
Edited by
!!!!!!!!!!ExclaimationMark #3
Posted 10 August 2014 - 01:29 PM
I saw that. still confused.
theoriginalbit #4
Posted 10 August 2014 - 02:22 PM
So if you saw it, why did you ask where the API was? :huh:/>

What is confusing about it?
TheOddByte #5
Posted 10 August 2014 - 03:55 PM
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 thischange this

local function sha256( message )
to this

function sha256( message )
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" ) )
!!!!!!!!!!ExclaimationMark #6
Posted 11 August 2014 - 01:15 AM
Oic
!!!!!!!!!!ExclaimationMark #7
Posted 11 August 2014 - 01:17 AM
Oh, and BTW, will it work on other Luas (e.g. OC Lua(5.2), Roblox Lua (5.1))
theoriginalbit #8
Posted 11 August 2014 - 02:17 AM
its a completely contained API, requiring nothing external, so yes, it should work. However the way you load it will differ.
!!!!!!!!!!ExclaimationMark #9
Posted 11 August 2014 - 06:40 AM
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
theoriginalbit #10
Posted 11 August 2014 - 06:48 AM
it can be external it doesn't have to be defined in the program.
Edited on 11 August 2014 - 04:48 AM