Page 1 of 1

sha1digest()

Posted: Fri May 04, 2012 5:04 am
by genie
I cannot seem to understand LiveCode's sha1 function...

sha1 of "234LK435J6345234LKJ234LKJ23403/24/2012 12:41Str8Arr0w%" is "fb221be295b72edfaa98b4b43c329df448df68d5"

but when I get sha1Digest(someData)

^this would return something like this...
˚"‚ï∑.fl™ò¥¥<2ùÙHflh’

Why is the function returning some weird characters instead of alphanumeric? Can somebody please help me? :? I'm trying to use the sha1 of some string and use it as a parameter in the URL, but the weird characters won't do.


Thank you so much! :)

Re: sha1digest()

Posted: Fri May 04, 2012 6:13 am
by shaosean
This function returns the sha-1 digest in the form of 20 (binary) bytes.
I do not use LiveCode, but this was some earlier code to convert the md5digest into a hex string, so see if will work for your sha1digest

Code: Select all

function hexDigest pvalue
  local tRes, tSHA1
  put sha1digest(pValue) into tSHA1
  get binaryDecode("H*",tSHA1,tRes)
  return tRes
end hexDigest
Rev really needs to update the online documentation as sha1digest is not listed..

Re: sha1digest()

Posted: Fri May 04, 2012 7:12 am
by genie
ohhhh! works great. :D Thanks much shaosean!