[kwlug-disc] Hash functions.

Joe Wennechuk youcanreachmehere at hotmail.com
Sun Jan 2 14:25:42 EST 2011


That is the rub, the size... I think I need an auto increment, but I would still like to obfuscate it somewhat I dont want it to look sequential. Am I thinking wrong? I just want to appear secure for the moment, or at least make it hard. I'm sure most of the coupons would be honored with or without the actual presentation; at least, thats been my experience in the low item value realm, if the coupons were for like $200 off I could understand, but for now I'm focusing on just individuaizing(Uniqueness generated in real time) to track redemption mostly. Each coupon shoud for the moment be in the cents or low dollars. At least until I can do some more testing and see if I really get collisions. I'm not sure about the math...
what is the least amount of (base n<127 bytes {no special characters please} )Some sms work on UTF-7 ???] that can represent 250 characters uniquely using time/date/message/fromID as inputs in 250 character blocks.


I think I'm over thinking this maybe??
Joseph Wennechuk

________________




Date: Sun, 2 Jan 2011 20:45:38 +0200
From: kb at 2bits.com
To: kwlug-disc at kwlug.org
Subject: Re: [kwlug-disc] Hash functions.

You just need to generate a quasi-unique number from a set of variables.

$ php -a
php > $string = "Something or other with date and time";
php > $hash = md5($string);
php > print $hash;

6d1740d6c0c59422b052916acb8ad778
Stuff what you want in $string, be it the store, date, whatever.

Then you can use the $hash value as the key in the database to track
this coupon.

All this would have worked if you have not said it should be short.


But you want it to be short, so the above may be too long.

Would this work? It is based on the microsecond time. If you
have a transaction every few seconds, then it should be OK.
Clashes can happen if you have two at the same exact micro-

second.

$ php -a
php > print uniqid();
4d20c753e4001

Short enough?

Another approach: why not use an autoincrement key in the database table 
that is the primary key for the coupon table, and be done with it? The

rest of the data can be cross indexed in that table (store ID, date,
time, description, ...etc.). It will be just a number.
-- 
Khalid M. Baheyeldin
2bits.com, Inc.
http://2bits.com

Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra
Simplicity is the ultimate sophistication. --   Leonardo da Vinci



_______________________________________________
kwlug-disc_kwlug.org mailing list
kwlug-disc_kwlug.org at kwlug.org
http://astoria.ccjclearline.com/mailman/listinfo/kwlug-disc_kwlug.org 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://astoria.ccjclearline.com/pipermail/kwlug-disc_kwlug.org/attachments/20110102/ad85083a/attachment.html>


More information about the kwlug-disc_kwlug.org mailing list