> What is the difference between Security::hash() & md5(). What size
> field do I need in my database for this?

let's explore using documentation to find the answer to this question, shall we.

According to http://us3.php.net/md5  the md5 function in php creates

"The hash is a 32-character hexadecimal number. If the optional
raw_output is set to TRUE, then the md5 digest is instead returned in
raw binary format with a length of 16."

Now by using the cake api documentation for Security::hash  (I'll use
the 1.2 version since that is where we are heading.  If find that
according to
<http://api.cakephp.org/1.2/classSecurity.html#27ea81806252a6f2420b216f00853839>
this uses by default sha1  (though you can specify sha256 and it falls
back to md5)  so let's assume you go with the default...

http://us3.php.net/sha lets us know that http://us3.php.net/sha1  "The
hash is a 40-character hexadecimal number. If the optional raw_output
is set to TRUE, then the sha1 digest is instead returned in raw binary
format with a length of 20."

If it uses sha256 this is a little harder to find but if you use the
link in the cake api to see the source (my what a little function this
is ;)  you will see it uses mhash and following the documentation
links in php.net will lead you eventually to
http://mhash.sourceforge.net/

And there ends the lesson ;)

Sam D

ps sorry for using your question for a snarky rude, inconsiderate
response, but I am a grumpy old fart, and I even answered your
question, which is rare for me ;)


>
> On Mar 21, 12:33 pm, "nate" <[EMAIL PROTECTED]> wrote:
> > FormHelper::password doesn't have a label option, it just renders a
> > password field.  Use the label() method.
> >
> > <?=$form->create('User', array('action' => 'register')) ?>
> >     <?=$form->inputs(array('first_name', 'last_name', 'email',
> > 'username', 'password'))?>
> >     <?=$form->label('confirm_password', 'Confirm your password')?><?=
> > $form->password('confirm_password')?>
> > <?=$form->submit('Register')?>
> >
> >         function register() {
> >                 if (!empty($this->data)) {
> >                         if ($this->User->save($this->data)) {
> >                                 // OK, everything is valid
> >                         } else {
> >                                 // Validation errors
> >                                 $this->set('errorMessage', 'Please
> > correct errors below.');
> >                                 $this->render();
> >                         }
> >                 }
> >         }
> >
> > class User extends AppModel {
> >     function beforeValidate() {
> >         if (!$this->exists()) {
> >             if ($this->data['User']['confirm_password'] != 
> > $this->data['User']['password']) {
> >
> >                $this->invalidate('confirm_password');
> >             }
> >         }
> >         if (isset($this->data['User']['password']) && 
> > !empty($this->data['User']['password'])) {
> >
> >             $this->data['User']['password'] = 
> > Security::hash($this->data['User']['password']);
> >
> >         }
> >         return true;
> >     }
> >
> > }
> >
> > On Mar 21, 1:42 pm, "xhenxhe" <[EMAIL PROTECTED]> wrote:
> >
> > > I'm new to this stuff. I've downloaded the latest 1.2 version this
> > > morning. I want create a simple user registration form. So far I have
> > > in my view:
> >
> > > <?=$form->create('User', array('action' => 'register'))?>
> > > <?=$form->input('first_name')?>
> > > <?=$form->input('last_name')?>
> > > <?=$form->input('email')?>
> > > <?=$form->input('username')?>
> > > <?=$form->input('password')?>
> > > <?=$form->password('confirm_password')?>
> > > <?=$form->submit('Register')?>
> >
> > > I took the following function almost directly from the manual:
> > >         function register() {
> > >                 if (empty($this->data)) {
> > >                         $this->render();
> > >                 }
> > >                 else {
> > >                         if ($this->User->save($this->data)) {
> > >                                 // OK, everything is valid
> > >                         }
> > >                         else {
> > >                                 // Validation errors
> > >                                 $this->set('errorMessage', 'Please 
> > > correct errors below.');
> > >                                 $this->render();
> > >                         }
> > >                 }
> > >         }
> >
> > > I have a few questions...
> > > 1. What option do I need to pass in the the formHelper::password
> > > method to get a label?
> > > 2. How would I check if my password matches the password confirmation?
> > > 3. How do I modify my function to md5 encrypt the password before
> > > storing it?
>
>
> >
>


-- 
(the old fart) the advice is free, the lack of crankiness will cost you

- its a fine line between a real question and an idiot

http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/

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

Reply via email to