Re: pgcryto strangeness... - Mailing list pgsql-hackers

From Sean Chittenden
Subject Re: pgcryto strangeness...
Date
Msg-id 20020105111110.T36993@ninja1.internal
Whole thread Raw
In response to pgcryto strangeness...  (Sean Chittenden <sean@chittenden.org>)
List pgsql-hackers
> > host=# SELECT DIGEST('asdf', 'md5') FROM users_shadow;
> >                      digest                     
> > ------------------------------------------------
> >  \221.\310\003\262\316I\344\245A\006\215IZ\265p
> > (1 row)
> 
> You must encode() the results.

Sorry for not being more clear, this isn't the problem: just proof
that things are working on this end.

> (For the record, I consider that a serious design flaw.
> It may not be possible to safely dump and restore tables
> containing unencoded 8-bit data.)

How about a digest_hex() method?

> > host=# SELECT DIGEST(password, 'md5') FROM users_shadow;
> > ERROR:  Function 'digest(varchar, unknown)' does not exist
> >         Unable to identify a function that satisfies the given argument types
> >         You may need to add explicit typecasts
> > host=# SELECT DIGEST(CAST(password AS bytea), CAST('md5' AS TEXT)) FROM users_shadow;
> > ERROR:  Cannot cast type 'varchar' to 'bytea'
>  
> Try dropping the first cast.

Already have.  I've cast it to text too.  I've even tried having it
operate on char and text column types, it's looking for a bytea data
type, but I don't know how to cast to that correctly and that's the
problem (with the module?).  Sorry I wasn't more explicitly earlier.  -sc

host=# SELECT DIGEST(CAST(enabled AS bytea), CAST('md5' AS TEXT)) FROM users_shadow;
ERROR:  Cannot cast type 'bpchar' to 'bytea'
host=# SELECT DIGEST(CAST(enabled AS text), CAST('md5' AS TEXT)) FROM users_shadow;
ERROR:  Function 'digest(text, text)' does not exist       Unable to identify a function that satisfies the given
argumenttypes       You may need to add explicit typecasts
 
host=# SELECT DIGEST(CAST(password AS text), CAST('md5' AS TEXT)) FROM users_shadow;
ERROR:  Function 'digest(text, text)' does not exist       Unable to identify a function that satisfies the given
argumenttypes       You may need to add explicit typecasts
 


-- 
Sean Chittenden


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Some interesting results from tweaking spinlocks
Next
From: Joe Conway
Date:
Subject: Re: pgcryto strangeness...