
I'm trying to reduce all the functions I have written for SHA-256.
The add binary function I have written needs to be shortened as it gets called most of the time. Can anyone reduce this code using LiveCodes inbuilt functions? The function needs to return a 32 bit number



-- v1 and v2 are 32 bit numbers
function ADDBINARY v1,v2
put "00000000000000000000000000000000" into v0
repeat with c = 32 down to 1
put char c of v0+char c of v1+char c of v2 into n
if n = "0" then put "0" before output else if n = "1" then put "1" before output
else
if n = "2" then put "0" before output else if n = "3" then put "1" before output
put "1" into char c-1 of v0
end if
end repeat
return output
end ADDBINARY