pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedMD5 in pg and php
10+ messages / 6 participants
[nested] [flat]
* MD5 in pg and php
@ 2004-04-29 07:07 Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 10:11 ` Re: MD5 in pg and php Bruno Wolff III <bruno@wolff.to>
0 siblings, 2 replies; 10+ messages in thread
From: Joolz @ 2004-04-29 07:07 UTC (permalink / raw)
To: pgsql-php
Hi, I'm completely new to hashing, so please bear with me.
I want to store passwords in a pg db, MD5 seems like a good way to
enhance security (no more plaintext passwords over the line etc.) I
had a look at MD5, in PHP 4.3.4 there is a function md5() which seems
to work nicely:
echo md5('apple');
returns ae6d32585ecc4d33cb8cd68a047d8434 every time. Apart from the
PHP frontend, I also want to be able to use the same algorithm in
native pg. I found that postgresql-contrib-7.3.4 has a function
crypt() which I expected to work the same. However:
select crypt('apple', gen_salt('md5'));
gives values different from the PHP md5() function, and moreover,
they're different each time. Can anyone please tell me what I should
do to get the same result in native pg as in PHP?
Thanks!
--
08:59-09:07
Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2188.nptl
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
@ 2004-04-29 08:31 ` Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
1 sibling, 1 reply; 10+ messages in thread
From: Marek Lewczuk @ 2004-04-29 08:31 UTC (permalink / raw)
To: pgsql-php
Joolz wrote:
> Hi, I'm completely new to hashing, so please bear with me.
>
> I want to store passwords in a pg db, MD5 seems like a good way to
> enhance security (no more plaintext passwords over the line etc.) I
> had a look at MD5, in PHP 4.3.4 there is a function md5() which seems
> to work nicely:
>
> echo md5('apple');
>
> returns ae6d32585ecc4d33cb8cd68a047d8434 every time. Apart from the
> PHP frontend, I also want to be able to use the same algorithm in
> native pg. I found that postgresql-contrib-7.3.4 has a function
> crypt() which I expected to work the same. However:
>
> select crypt('apple', gen_salt('md5'));
>
> gives values different from the PHP md5() function, and moreover,
> they're different each time. Can anyone please tell me what I should
> do to get the same result in native pg as in PHP?
>
> Thanks!
>
I whould suggest to update PG to version 7.4, where there is built-in
MD5 function.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
@ 2004-04-29 08:15 ` Joolz <joolz@xs4all.nl>
2004-04-29 08:30 ` Re: MD5 in pg and php Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2004-04-29 08:49 ` Re: MD5 in pg and php Stefan Sturm <mailling@anrath.info>
2004-04-29 08:50 ` Re: MD5 in pg and php Nick Barr <nicky@chuckie.co.uk>
2004-04-29 09:49 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
0 siblings, 4 replies; 10+ messages in thread
From: Joolz @ 2004-04-29 08:15 UTC (permalink / raw)
To: pgsql-php
> [Marek Lewczuk schreef op 29-04-2004 09:31 +0100]
>
> Joolz wrote:
> >Hi, I'm completely new to hashing, so please bear with me.
> >
> >I want to store passwords in a pg db, MD5 seems like a good way to
> >enhance security (no more plaintext passwords over the line etc.) I
> >had a look at MD5, in PHP 4.3.4 there is a function md5() which seems
> >to work nicely:
> >
> > echo md5('apple');
> >
> >returns ae6d32585ecc4d33cb8cd68a047d8434 every time. Apart from the
> >PHP frontend, I also want to be able to use the same algorithm in
> >native pg. I found that postgresql-contrib-7.3.4 has a function
> >crypt() which I expected to work the same. However:
> >
> > select crypt('apple', gen_salt('md5'));
> >
> >gives values different from the PHP md5() function, and moreover,
> >they're different each time. Can anyone please tell me what I should
> >do to get the same result in native pg as in PHP?
> >
> >Thanks!
> >
>
> I whould suggest to update PG to version 7.4, where there is built-in
> MD5 function.
Thanks, I already found some fc1 rpm's (still in development). But can
anyone tell me if the 7.4 internal md5() function will do the same as
the PHP md5() function? Or do a quick select md5('apple') and let me
know if the result is 'ae6d32585ecc4d33cb8cd68a047d8434'?
I really wouldn't like to upgrade from my current stable situation,
only to find out that it didn't solve my original problem.
TIA!
--
10:14-10:15
Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2188.nptl
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
@ 2004-04-29 08:30 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
3 siblings, 0 replies; 10+ messages in thread
From: Christopher Kings-Lynne @ 2004-04-29 08:30 UTC (permalink / raw)
To: pgsql-php
> Thanks, I already found some fc1 rpm's (still in development). But can
> anyone tell me if the 7.4 internal md5() function will do the same as
> the PHP md5() function? Or do a quick select md5('apple') and let me
> know if the result is 'ae6d32585ecc4d33cb8cd68a047d8434'?
>
> I really wouldn't like to upgrade from my current stable situation,
> only to find out that it didn't solve my original problem.
Postgres 7.4:
usa=> select md5('apple');
md5
----------------------------------
1f3870be274f6c49b3e31a0c6728957f
(1 row)
And my PHP:
bash-2.05a$ php -q
<?php echo md5('apple') ?>
1f3870be274f6c49b3e31a0c6728957f
So mine are the same, but yours is completely different to anything.
Chris
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
@ 2004-04-29 08:49 ` Stefan Sturm <mailling@anrath.info>
3 siblings, 0 replies; 10+ messages in thread
From: Stefan Sturm @ 2004-04-29 08:49 UTC (permalink / raw)
To: pgsql-php
Hello,
> I really wouldn't like to upgrade from my current stable situation,
> only to find out that it didn't solve my original problem.
I did a "select md5('apple');". PostgreSQL 7.4.2
For me, the result is: 1f3870be274f6c49b3e31a0c6728957f
In php I did a "echo md5('apple');". php 4.3.6
The result in php is also: 1f3870be274f6c49b3e31a0c6728957f
I don't now, how you get your answer...
Greetings,
Stefan Sturm
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
@ 2004-04-29 08:50 ` Nick Barr <nicky@chuckie.co.uk>
3 siblings, 0 replies; 10+ messages in thread
From: Nick Barr @ 2004-04-29 08:50 UTC (permalink / raw)
To: pgsql-php
Joolz wrote:
>>[Marek Lewczuk schreef op 29-04-2004 09:31 +0100]
>>
>>Joolz wrote:
>>
>>
>>>Hi, I'm completely new to hashing, so please bear with me.
>>>
>>>I want to store passwords in a pg db, MD5 seems like a good way to
>>>enhance security (no more plaintext passwords over the line etc.) I
>>>had a look at MD5, in PHP 4.3.4 there is a function md5() which seems
>>>to work nicely:
>>>
>>> echo md5('apple');
>>>
>>>returns ae6d32585ecc4d33cb8cd68a047d8434 every time. Apart from the
>>>PHP frontend, I also want to be able to use the same algorithm in
>>>native pg. I found that postgresql-contrib-7.3.4 has a function
>>>crypt() which I expected to work the same. However:
>>>
>>> select crypt('apple', gen_salt('md5'));
>>>
>>>gives values different from the PHP md5() function, and moreover,
>>>they're different each time. Can anyone please tell me what I should
>>>do to get the same result in native pg as in PHP?
>>>
>>>Thanks!
>>>
>>>
>>>
>>I whould suggest to update PG to version 7.4, where there is built-in
>>MD5 function.
>>
>>
>
>Thanks, I already found some fc1 rpm's (still in development). But can
>anyone tell me if the 7.4 internal md5() function will do the same as
>the PHP md5() function? Or do a quick select md5('apple') and let me
>know if the result is 'ae6d32585ecc4d33cb8cd68a047d8434'?
>
>I really wouldn't like to upgrade from my current stable situation,
>only to find out that it didn't solve my original problem.
>
>TIA!
>
>
>
OK, PHP
---------------------------------------------------
<?
echo md5('apple');
?>
---------------------------------------------------
produces
---------------------------------------------------
1f3870be274f6c49b3e31a0c6728957f
---------------------------------------------------
and postgres:
---------------------------------------------------
im_perf=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.2
20031022 (Red Hat Linux 3.3.2-1)
(1 row)
im_perf=# select md5('apple');
md5
----------------------------------
1f3870be274f6c49b3e31a0c6728957f
(1 row)
---------------------------------------------------
I have no idea why these two results dont agree with yours, but at least
they agree with each other. It is probasbly different library versions.
Nick
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
@ 2004-04-29 09:49 ` Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:54 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
3 siblings, 1 reply; 10+ messages in thread
From: Marek Lewczuk @ 2004-04-29 09:49 UTC (permalink / raw)
To: pgsql-php; joolz@xs4all.nl
Joolz wrote:
>>[Marek Lewczuk schreef op 29-04-2004 09:31 +0100]
>>
> Thanks, I already found some fc1 rpm's (still in development). But can
> anyone tell me if the 7.4 internal md5() function will do the same as
> the PHP md5() function? Or do a quick select md5('apple') and let me
> know if the result is 'ae6d32585ecc4d33cb8cd68a047d8434'?
>
> I really wouldn't like to upgrade from my current stable situation,
> only to find out that it didn't solve my original problem.
>
> TIA!
>
I have 7.4.1 version and "select md5('apple')" returns:
1f3870be274f6c49b3e31a0c6728957f
But I have checked in my PHP 4.3 what will return md5('apple') and:
1f3870be274f6c49b3e31a0c6728957f
So as you see there are the same - but they are different from your result.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 09:49 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
@ 2004-04-29 08:54 ` Joolz <joolz@xs4all.nl>
2004-04-29 09:26 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
0 siblings, 1 reply; 10+ messages in thread
From: Joolz @ 2004-04-29 08:54 UTC (permalink / raw)
To: pgsql-php
> [Marek Lewczuk schreef op 29-04-2004 10:49 +0100]
>
> Joolz wrote:
> >>[Marek Lewczuk schreef op 29-04-2004 09:31 +0100]
> >>
> >Thanks, I already found some fc1 rpm's (still in development). But can
> >anyone tell me if the 7.4 internal md5() function will do the same as
> >the PHP md5() function? Or do a quick select md5('apple') and let me
> >know if the result is 'ae6d32585ecc4d33cb8cd68a047d8434'?
> >
> >I really wouldn't like to upgrade from my current stable situation,
> >only to find out that it didn't solve my original problem.
> >
> >TIA!
> >
>
> I have 7.4.1 version and "select md5('apple')" returns:
> 1f3870be274f6c49b3e31a0c6728957f
>
> But I have checked in my PHP 4.3 what will return md5('apple') and:
> 1f3870be274f6c49b3e31a0c6728957f
>
> So as you see there are the same - but they are different from your result.
Thanks for testing this!
I'm not sure if I'm happy with the outcome... Seems as if the result
of both md5() functions depends on something outside of PHP and
postgresql... Which could mean that if I backup my db and restore it
on another server (which of course should be possible) all my
passwords will be broken :-(
I guess I'll have to take a better look at how md5 works...
Thanks again!
--
10:50-10:54
Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2188.nptl
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 09:49 ` Re: MD5 in pg and php Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:54 ` Re: MD5 in pg and php Joolz <joolz@xs4all.nl>
@ 2004-04-29 09:26 ` Joolz <joolz@xs4all.nl>
0 siblings, 0 replies; 10+ messages in thread
From: Joolz @ 2004-04-29 09:26 UTC (permalink / raw)
To: pgsql-php
> [Joolz schreef op 29-04-2004 10:54 +0200]
...
> I guess I'll have to take a better look at how md5 works...
(foot in brain)
I had a typo on my testcode, now I get
1f3870be274f6c49b3e31a0c6728957f too.
Thanks everyone, I will have a look at what's changed between 7.3.4
and 7.4.2 and then (probably) upgrade.
--
11:23-11:26
Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2188.nptl
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: MD5 in pg and php
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
@ 2004-04-29 10:11 ` Bruno Wolff III <bruno@wolff.to>
1 sibling, 0 replies; 10+ messages in thread
From: Bruno Wolff III @ 2004-04-29 10:11 UTC (permalink / raw)
To: pgsql-php
On Thu, Apr 29, 2004 at 09:07:16 +0200,
Joolz <joolz@xs4all.nl> wrote:
>
> I want to store passwords in a pg db, MD5 seems like a good way to
> enhance security (no more plaintext passwords over the line etc.) I
> had a look at MD5, in PHP 4.3.4 there is a function md5() which seems
> to work nicely:
This may not help as much as you think. If you are using an ssl connection,
the passwords won't be sent in the clear. If you aren't using an ssl
connection the hashes will be in clear. I don't believe the postgres
uses a random challenge so that you won't really raise the bar much.
Plus if snooping passwords is a threat, most likely snooping data will
be as well (though not always) and forcing connections to use ssl may be
your best bet. I believe as typically used this is vulnerable to man in
the middle attacks, but these are going to be significantly harder to do than
simple snooping.
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2004-04-29 10:11 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-29 07:07 MD5 in pg and php Joolz <joolz@xs4all.nl>
2004-04-29 08:31 ` Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:15 ` Joolz <joolz@xs4all.nl>
2004-04-29 08:30 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2004-04-29 08:49 ` Stefan Sturm <mailling@anrath.info>
2004-04-29 08:50 ` Nick Barr <nicky@chuckie.co.uk>
2004-04-29 09:49 ` Marek Lewczuk <newsy@lewczuk.com>
2004-04-29 08:54 ` Joolz <joolz@xs4all.nl>
2004-04-29 09:26 ` Joolz <joolz@xs4all.nl>
2004-04-29 10:11 ` Bruno Wolff III <bruno@wolff.to>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox