Tuesday, June 30, 2009

Re: How to generate a hash that is valid for 48 hrs?

I wouldn't bother trying to include (and parse out) the date in the
hash. Create a table to store the hashes and include a "created
DATETIME DEFAULT NULL" column. This way, you can later use your DB's
date/time functions to check if it's within the 48 hours. When the
hash is used, remove it from the DB.

On Tue, Jun 30, 2009 at 7:51 PM,
DigitalDude<e.blumstengel@googlemail.com> wrote:
>
> Hey,
>
> I need a way to generate a hash code, which is valid 48 hrs. after it
> has been generated. I need this to register my users and to activate
> them.
>
> I have the problem that this code below does generate a hash for 2
> days, but this will cause problems when a user registers at 23:56, so
> the hash will only be valid for the next day because it does not hash
> correctly. I need a generation in hours, but I can't figure out how to
> do that.
>
> Here's what I got so far...:
>
> return substr(Security::hash(Configure::read('Security.salt') . $this-
>>field('created') . date('Y-m-d', strtotime("+2 days"))), 0, 20);
>
> The hash is generated by hashing the security salt, the date the user
> is created and the actual date + 2 days. It should contain 20 digits.
> When I try to put +48 hrs into the code instead of +2 days the hash
> will not be accepted anymore.
>
> Would be nice if someone could help me on this one...
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: