sha1digest()

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

sha1digest()

Post by genie » Fri May 04, 2012 5:04 am

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! :)

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: sha1digest()

Post by shaosean » Fri May 04, 2012 6:13 am

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..

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: sha1digest()

Post by genie » Fri May 04, 2012 7:12 am

ohhhh! works great. :D Thanks much shaosean!

Post Reply