Page 1 of 1

using the "value" command and passing variables

Posted: Mon Jun 17, 2013 11:43 pm
by makeshyft
Hi everyone,

I have just spent a few hours trying to solve this and for the life of me I cannot. In my main stack I have a function called "UMP_HEXDigest"

it converts 20 bit sha1digest values to a normal string.

It works fine on its own.

But to when I try to envoke the function from elsewhere using the VALUE command, it just don't play nice. Its not allowing me to use a variablename as a parameter for the function. When it works, it returns the LITERAL value of the variable name and not the content of the variable. I've played with the syntax and I can't seem to get it.

Seems to me that is a limitation of the VALUE command.

PS ... I am taking "it" from ask password, putting it into a variable and then trying to hash it using the function.

Is there a workaround for this?

Re: using the "value" command and passing variables

Posted: Mon Jun 17, 2013 11:54 pm
by FourthWorld
The "value" function is a tricky beast, similar to JavaScript's "eval" in that it attempts to evaluate the expression passed into it. Since the data returned from sha1Digest is binary, it may just be that "value" is tripping up trying to figure out how it's a LiveCode expression.

For hash output as hex, try the binaryDecode function:

Code: Select all

function CleanHash pString
   local tHex
   get binaryDecode("h*", sha1digest(pString), tHex)
   return tHex
end CleanHash

Re: using the "value" command and passing variables

Posted: Tue Jun 18, 2013 12:01 am
by makeshyft
ahhh shikes..... that makes perfect sense.....why convert it if I can just output the proper string to begin with.

Richard.... I can't tell you how much I appreciate all the times you have helped me already and its only been 2 months since I've been here. You are building up some good karma my friend.

Re: using the "value" command and passing variables

Posted: Tue Jun 18, 2013 12:51 am
by FourthWorld
I'm just paying it forward, Tom. All these years I've been the lucky recipient of many people's patient assistance. Passing some of that along is the least I can do.