[kwlug-disc] Hash functions.
John Van Ostrand
john at netdirect.ca
Sun Jan 2 15:40:58 EST 2011
It seems to me a uuid + auto increment is easy, unique and secure with no
need to compromise.
_____
From: kwlug-disc-bounces at kwlug.org
To: kwlug-disc at kwlug.org
Sent: Sun Jan 02 14:25:42 2011
Subject: Re: [kwlug-disc] Hash functions.
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://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20110102/ce4b1d69/attachment.htm>
More information about the kwlug-disc
mailing list