[SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread Subhramanya Shiva

hi all

how to store password details in a table. in encoded form
and how to decode it.

in mysql ...we r having encoding and decoding for a password
security ... so how to do in pgsql...

regards
Shiva.

-- 
Subhramanya Shiva, Programmer
Archean InfoTech pvt.Ltd.
Hyderabad, India
http://www.archeanit.com



---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread D'Arcy J.M. Cain

Thus spake Subhramanya Shiva
> how to store password details in a table. in encoded form
> and how to decode it.
> 
> in mysql ...we r having encoding and decoding for a password
> security ... so how to do in pgsql...

You use the chkpass type that I just commited to the distribution (finally.)
Here is an example of its usage.

darcy=# CREATE TABLE x (i serial, p chkpass);
NOTICE:  CREATE TABLE will create implicit sequence 'x_i_seq' for SERIAL column 'x.i'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'x_i_key' for table 'x'
CREATE
darcy=# INSERT INTO x (p) VALUES ('hello');
INSERT 805247 1
darcy=# INSERT INTO x (p) VALUES ('goodbye');
INSERT 805248 1
darcy=# SELECT * FROM x;
 i |   p
---+
 1 | :SoLA2YFpQYV/I
 2 | :Sg8CKkFqqTGec
(2 rows)

darcy=# SELECT p = 'hello' FROM x WHERE i = 1;
 ?column? 
--
 t
(1 row)

darcy=# SELECT p = 'hello' FROM x WHERE i = 2;
 ?column? 
--
 f
(1 row)

darcy=# SELECT i, raw(p) FROM x;
 i |  raw  
---+---
 1 | SoLA2YFpQYV/I
 2 | Sg8CKkFqqTGec
(2 rows)

-- 
D'Arcy J.M. Cain|  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



[SQL] '13 months ago'::reltime

2001-05-03 Thread Albert REINER

Saluton,

I do not quite understand the following:

,
| albert=> select '13 months ago'::reltime;
|   ?column?
| -
|  1 year 25 00:00 ago
| (1 row)
| 
| albert=> select '13 months ago'::interval;
| ?column?
| 
|  1 year 1 mon 00:00 ago
| (1 row)
| 
| albert=> select version();
|   version
| 
|  PostgreSQL 7.0.2 on i586-pc-linux-gnulibc1, compiled by gcc 2.95.1
| (1 row)
`

Shouldn't 13 months be 1 year and 1 month even for reltime?

Somewhat puzzled,

Albert.


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: [SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread Josh Berkus

D'Arcy,

> You use the chkpass type that I just commited to the distribution
> (finally.)
> Here is an example of its usage.

Does that mean that chkpass is part of 7.1, or only  the current CVS?

-Josh

__AGLIO DATABASE SOLUTIONS___
   Josh Berkus
  Complete information technology  [EMAIL PROTECTED]
   and data management solutions   (415) 565-7293
  for law firms, small businessesfax 621-2533
and non-profit organizations.  San Francisco

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread Tom Lane

"Josh Berkus" <[EMAIL PROTECTED]> writes:
>> You use the chkpass type that I just commited to the distribution

> Does that mean that chkpass is part of 7.1, or only  the current CVS?

Unless someone rips it out again, it will be part of 7.1.1.

I think D'Arcy acted inappropriately in committing a new-feature item
before we'd made the branch for 7.2 development.  But I don't have the
time to argue about it...

regards, tom lane

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



Re: [SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread Bruce Momjian

[ Charset ISO-8859-1 unsupported, converting... ]
> D'Arcy,
> 
> > You use the chkpass type that I just commited to the distribution
> > (finally.)
> > Here is an example of its usage.
> 
> Does that mean that chkpass is part of 7.1, or only  the current CVS?
> 

It will appear in 7.1.1, to be released soon.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



Re: [SQL] '13 months ago'::reltime

2001-05-03 Thread Tom Lane

Type reltime is old and deprecated.  Don't use it.

regards, tom lane

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



RE: [SQL] "correct" sorting.

2001-05-03 Thread Gerald Gutierrez



That list looks like an ordering that is custom to your application. The
latter sort created by the SQL seems more typical (correct?) to me.

I would return the table unsorted, and write the sorting routine in the
calling code instead.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jeff MacDonald
Sent: Wednesday, May 02, 2001 9:41 PM
To: [EMAIL PROTECTED]
Subject: [SQL] "correct" sorting.


Hi folks,

say i have a text field with teh values

1,2,3,10,20,30,1a,1b,2a,2b

and i want to sort it so i get,

1
1a
1b
2
2a
2b
3
10
20
30

is there anyway to do that with postgresql ?
below is what actually happens.

jeff=> select * from foo order by var1;
 var1
--
 1
 10
 1a
 1b
 2
 20
 2a
 2b
 3
 30
 3a
 3b
(12 rows)


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



[SQL] RE: "correct" sorting.

2001-05-03 Thread Joel Burton

On Thu, 3 May 2001, Gerald Gutierrez wrote:

> Hi folks,
> 
> say i have a text field with teh values
> 
> 1,2,3,10,20,30,1a,1b,2a,2b
> 
> and i want to sort it so i get,
> 
> 1
> 1a
> 1b
> 2
> 2a
> 2b
> 3
> 10
> 20
> 30
> 
> is there anyway to do that with postgresql ?
> below is what actually happens.
> 
> jeff=> select * from foo order by var1;
>  var1
> --
>  1
>  10
>  1a
>  1b
>  2
>  20
>  2a
>  2b
>  3
>  30
>  3a
>  3b
> (12 rows)

Hmmm... howzabout



create a function order_val(text) returning an integer, which is
equal to the the input, coerced into an integer (for simple things, like
10, 20, etc.), but equal to 10.01 for 10a, 10.02 for 10b, 10.25 for 10z.
(pl/perl, pl/tcl, or pl/python might be a quicker choice for this than
pl/pgsql)

You could then

SELECT id FROM tbl ORDER BY order_val(id);

And you could even index on order_val(id), so that it runs a bit faster.



-- 
Joel Burton   <[EMAIL PROTECTED]>
Director of Information Systems, Support Center of Washington


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



Re: [SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread Roberto Mello

On Wed, May 02, 2001 at 01:07:57AM +0530, Subhramanya Shiva wrote:
> hi all
> 
> how to store password details in a table. in encoded form
> and how to decode it.
> 
> in mysql ...we r having encoding and decoding for a password
> security ... so how to do in pgsql...

I usually do the encrypting in the client application (AOLserver, PHP),
store the encrypted password, when the user comes back and enters the
password I encrypt it and test it against what's on the database.

-Roberto
-- 
+| http://fslc.usu.edu USU Free Software & GNU/Linux Club |--+
  Roberto Mello - Computer Science, USU - http://www.brasileiro.net 
   http://www.sdl.usu.edu - Space Dynamics Lab, Developer
Thou shall not kill, unless it's for dinner!

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



Re: [SQL] How to encode and decode password in pgsql !!

2001-05-03 Thread Subhramanya Shiva

i could not find chkpass in pgsql datatypes ...
it is giving error called : 

Unable to locate type name chkpass in catalog.

what shall i do ??

regards
Shiva.

> Thus spake Subhramanya Shiva
> > how to store password details in a table. in encoded form
> > and how to decode it.
> > 
> > in mysql ...we r having encoding and decoding for a password
> > security ... so how to do in pgsql...
> 
> You use the chkpass type that I just commited to the distribution 
(finally.)
> Here is an example of its usage.
> 
> darcy=# CREATE TABLE x (i serial, p chkpass);
> NOTICE:  CREATE TABLE will create implicit sequence 'x_i_seq' for SERIAL 
column 'x.i'
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'x_i_key' for 
table 'x'
> CREATE
> darcy=# INSERT INTO x (p) VALUES ('hello');
> INSERT 805247 1
> darcy=# INSERT INTO x (p) VALUES ('goodbye');
> INSERT 805248 1
> darcy=# SELECT * FROM x;
>  i |   p
> ---+
>  1 | :SoLA2YFpQYV/I
>  2 | :Sg8CKkFqqTGec
> (2 rows)
> 
> darcy=# SELECT p = 'hello' FROM x WHERE i = 1;
>  ?column? 
> --
>  t
> (1 row)
> 
> darcy=# SELECT p = 'hello' FROM x WHERE i = 2;
>  ?column? 
> --
>  f
> (1 row)
> 
> darcy=# SELECT i, raw(p) FROM x;
>  i |  raw  
> ---+---
>  1 | SoLA2YFpQYV/I
>  2 | Sg8CKkFqqTGec
> (2 rows)
> 
> -- 
> D'Arcy J.M. Cain|  Democracy is three wolves
> http://www.druid.net/darcy/|  and a sheep voting on
> +1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
> 


-- 
Subhramanya Shiva, Programmer
Archean InfoTech pvt.Ltd.
Hyderabad, India
http://www.archeanit.com



---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])