Just tried the following code, it works :) Only change is that I don't
use the variable $key!

[code]
         $hashCode = mhash(MHASH_SHA256, 'ENCRYPTIONISAGOODTHING',
true);
         pr($hashCode);
[/code]

Or now that I look at it, maybe that your are using $key both as input
and output! Check it out! :)
Enjoy,
   John

On Jan 11, 9:28 pm, David Brisebois <david.briseb...@gmail.com> wrote:
> Thanks for your answer !
>
> For the error, I was using $this->cakeError() but I taught it was the
> problem so that's why I replaced them with the comment so it is easy
> to put the error back.
>
> When reading your answer I made some search to find out that the mhash
> type exists, but that it is deprecated for hash so I changed it, set
> the third parameter to true (I need the raw binary result) and... same
> error ! I really thing the problem is the that I need the binary
> result because when I set it to false (to get hexadecimal) everything
> works fine except the Live ID token can't be decoded since the key is
> not the wright one...
>
> Any idea ?
>
> On 11 jan, 13:34, John Andersen <j.andersen...@gmail.com> wrote:
>
> > Are you sure that the mhash type MHASH_SHA256 exists?
> > Instead of just commenting out THROW ERROR, make a return( null );
> > Enjoy,
> >    John
>
> > On Jan 11, 5:40 am, David Brisebois <david.briseb...@gmail.com> wrote:
>
> > > Hi there !
>
> > > I am "baking" up a new website which will use the Windows Live ID Web
> > > Authentification service in order to access the web site. Based on the
> > > PHP file provided in the SDK, I made my own component which works
> > > fairly well (it still need some optimization).
>
> > > The only weird thing is that calling the function that derives the
> > > secret key to use the service make the Controller dump disappear. I
> > > tries everything, from changing function names, doing the logic in
> > > startup or with a direct call... and so on. But I found that the
> > > problem is when I try to save the deriviated key to an attribute... To
> > > help you understand here are the two method as they are now :
>
> > > function set_key()
> > >         {
> > >                 $this->derive( 'SIGNATURE' );
> > >                 $this->crypt_key = $this->derive( 'ENCRYPTION' );
> > >         }
>
> > >         function derive( $prefix = null )
> > >         {
> > >                 if ( is_null( $prefix ) ) {
> > >                         //THROW ERROR
> > >                 }
>
> > >                 $length = 16;
> > >                 $key = $prefix . $this->app_key;
> > >                 $key = mhash( MHASH_SHA256, $key );
> > >                 if ( !$key || ( strlen($key) < $length ) )
> > >                 {
> > >                         //THROW ERROR
> > >                 }
>
> > >                 return substr($key, 0, $length);
> > >         }
>
> > > If you use the code as shown above, the dump is hiden, if you comment
> > > out the second call to derive() in the set_key() function, it is
> > > not... but I really need them to be stored in an attribute !
>
> > > Any idea on what happens ?
>
> > > Thanks.
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to