How to create a Sha1 Digest UUID from a string?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

How to create a Sha1 Digest UUID from a string?

Post by William Jamieson » Mon Oct 19, 2015 9:29 am

I saw this forum thread: http://forums.livecode.com/viewtopic.ph ... 15&p=72918

There are no livecode lessons for this. The dictionary talks about namespaces and names, but I couldn't find out what those mean in the dictionary. I checked stack overflow, LC facebook page, etc. and still can't find any examples. So I thought I would ask you guys.

How do you create a UUID from a string?

I am trying to build a string that turns into a hex Sha1.

Code: Select all

put "public_id=" & kPublicID & "&timestamp=" & the seconds & kSecret into tKey
put UUID("SHA1", tKey) into sTokenID
That is what I want to write but it wont even let me save it. So what can I do to make this right?

Thanks guys n gals!

-Will
Last edited by William Jamieson on Mon Oct 19, 2015 10:38 am, edited 2 times in total.

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: How to create a UUID from a string?

Post by William Jamieson » Mon Oct 19, 2015 9:47 am

Ok I found this code

Code: Select all

command hexDigest 
   local tRes, tSHA1
   put "public_id=" & kPublicID & "&timestamp=" & the seconds & kSecret into tKey
  put sha1digest(tKey) into tSHA1
  get binaryDecode("H*",tSHA1,tRes)
end hexDigest
In this thread.

http://forums.livecode.com/viewtopic.ph ... est#p55830

Can someone with tell me if this is correct? Thanks

-Will

scrabbles
Posts: 25
Joined: Sat Dec 20, 2014 4:32 am

Re: How to create a Sha1 Digest UUID from a string?

Post by scrabbles » Mon Oct 19, 2015 10:53 am

Hi Will,

That sha1digest code you found looks like it might work to me, but you should be able to use the uuid("sha1",uuid(),"api_secret") format as well, just depends on what you're supposed to use from cloudinary (maybe grep their doco for namespace_ i'm guessing it wll be url).

I found this on SO which might help explain it http://stackoverflow.com/questions/1086 ... -namespace . The python doco is also not bad for this too https://docs.python.org/3.0/library/uuid.html

hope that helps

– Mark

Post Reply