Forum Moderators: phranque

Message Too Old, No Replies

Create an secure unique number or code

How can this be done?

         

Compworld

9:46 am on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to some how generate a unique code or number sequence for each lead from a site that will be referring traffic to my site. How can this be done? It would also have to be able to be transmitted over SSL.

Any tips will really be appreciated.

Thanks,

CompWorld

rogerdp

10:16 am on Mar 13, 2004 (gmt 0)

10+ Year Member



What is wrong with starting with 1 and adding 1 each time you need another?

Compworld

10:34 am on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

One of the marketing companies that we want to work with requires a unique variable for every lead that they send us. So, I need to so how have a way to pull the unique variable from the confirmation page so that they would have this unique information for each referrer that they send us.

Is this possible?

Thanks,

CompWorld

rharri

3:25 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



Do a search for "password generator". There are several freeware and open source ones that you can set the length of the "password" and make it all numbers or mixed if you wish.

rogerdp

11:40 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



A password generator won't create unique strings.

txbakers

1:03 am on Mar 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



do you have ASP or CGI available?
You could store the number in adatabase or simple text file and just retrieve the number + 1

okrogius

2:18 am on Mar 14, 2004 (gmt 0)

10+ Year Member



Just use concenate current unix timestamp and a (pseudo-) randomly generated number of five digits or so. The chances of ever getting the same "ID" is slim to none.

If you need this "algorithm" to remain secret then just hash the above (md5 or sha1) while adding a secret salt.

Compworld

2:42 pm on Mar 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I have both ASP & CGI. Been having a problem with Perl, but ASP works fine.

Thanks,

CompWorld

too much information

2:57 pm on Mar 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



why not just add the date/time to the string?

if you combine the two and do a replace to remove the formatting of the strings you should end up with a unique string for every hit. (as long as they do not happen in the same exact second.)

rogerdp

8:32 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



During peak times it is very, very possible to get two hits in the same second.

Ares

5:19 pm on Mar 16, 2004 (gmt 0)

10+ Year Member



Well you stated that you are having some trouble with ASP currently but here is one script you might want to take a quick look at:
======================================================
# create a unique session id
# input - string to use as part of the data used to create the session key.
# Although not required, it is best if this includes some unique
# data from the site, such as it's IP address or other environment
# information. For ZOPE applications, pass in the entire ZOPE "REQUEST"
# object.
def makeSessionId(st):
import md5, time, base64
m = md5.new()
m.update('this is a test for your marketing firm')
m.update(str(time.time()))
m.update(str(st))
return string.replace(base64.encodestring(m.digest())[:-3], '/', '$')

=====================================================

I'm sure I have a cgi version around some place as well...bear with me as I search and get back. Feel free to drop me a line if you wish

Ares

5:20 pm on Mar 16, 2004 (gmt 0)

10+ Year Member



AH! Look at that it was actual Perl your having trouble with.

Let me know if this works out for you or if you might need more information.

Compworld

10:53 pm on Mar 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Going to try it out.

Thanks,

CompWorld