Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Martin Hewitt
Hi Patrick, Thanks for this link, very useful class! I've ended up with much the same code snippet, I think during testing my brain, and database, got a bit muddled. Martin Sent from my iPhone On 23 Mar 2011, at 23:15, Patrick Barnes wrote: > Hi Martin, > > There is an example in php here:

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Patrick Barnes
Hi Martin, There is an example in php here: https://github.com/dready92/PHP-on-Couch/blob/master/lib/couchAdmin.php#L163 On 23/03/2011 2:33 PM, Martin Hewitt wrote: Hi all, I'm writing a build process in Phing, part of which involves creating a new CouchDB user. I'm having trouble logging in

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread David Coallier
Hey there Martin, You should be able to set the value to a normal string, IE: $user['password_sha'] = hash('sha256', $salt . $pass . $salt); or if you really want sha1 and you absolutely can't use sha256 $user['password_sha'] = hash('sha1', $salt . $pass . $salt); or $user['password_sha'] = sha

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Martin Hewitt
Looks like just using the raw string value works. Not sure if I mis-read the documentation or if it's something to do with PHP's native JSON conversion... Martin On 23 Mar 2011, at 13:13, Stefan Matheis wrote: > Hey again, > > just wondering about the following lines > >> $salt = "qwertyuiop

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Martin Hewitt
Hi Stefan, From here: http://wiki.apache.org/couchdb/Security_Features_Overview#Authorization "The salt attribute is the hexadecimal representation of the salt used to generate the user's password hash." Might have gotten the wrong end of the stick though... Martin On 23 Mar 2011, at 13:13,

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Stefan Matheis
Hey again, just wondering about the following lines > $salt = "qwertyuiop"; > $user['salt'] = bin2hex($salt); is that really, what you want to do / what couch requires you to do? $ php -r 'var_dump("qwertyuiop", bin2hex("qwertyuiop"));' string(10) "qwertyuiop" string(20) "71776572747975696f70"

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Martin Hewitt
Hi all, Just wondering if anyone has done this successfully in PHP and could offer advice? My code is currently: $user = array(); $user['_id'] = "org.couchdb.user:".$newUser; $user['type'] = "user"; $user['name'] = $newUser; $user['roles'] = "numpty"; $salt = "qwertyuiop"; $newPassword = "test

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Martin Hewitt
Hi Stefan, Thanks, looks like it's my fault after all! Martin Sent from my iPhone On 23 Mar 2011, at 08:40, Stefan Matheis wrote: > Martin, > > based on > http://wiki.apache.org/couchdb/Security_Features_Overview#Generating_password_sha > what's wrong about php's sha1() function? > > $ php

Re: PHP-based SHA1 algorithm?

2011-03-23 Thread Stefan Matheis
Martin, based on http://wiki.apache.org/couchdb/Security_Features_Overview#Generating_password_sha what's wrong about php's sha1() function? $ php -r "echo sha1('foobar');" 8843d7f92416211de9ebb963ff4ce28125932878 it's the same result as stated there for erlang, ruby & python :) Regards Stefan

PHP-based SHA1 algorithm?

2011-03-22 Thread Martin Hewitt
Hi all, I'm writing a build process in Phing, part of which involves creating a new CouchDB user. I'm having trouble logging in as the created user and have an inkling that it's down to the SHA1 encryption of the password and salt, as the Security wiki page is quite specific about what SHA1s wo