Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server 2000

Author  Topic 

anu_mca_knit
Starting Member

2 Posts

Posted - 2007-05-11 : 03:32:05
I have a column user_password in my table that keeps the password of the users.
When i use select user_password from table_name
then all the values are shown in query analyzer as they are.
But i want to show only stars(*) .
How to solve this problem???

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-11 : 03:36:52
How about this?

SELECT COL1, COL2, REPLICATE(DATALENGTH(PASSWORD), '*') AS PASSWORD
FROM TABLE


Just kidding !!

Frankly this is a front-end issue and better handled there.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-11 : 04:32:31
don't store passwords in plain text at all.
hash them with MD5 and insert the hash into the db.


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-11 : 04:32:39
quote:
Originally posted by harsh_athalye

How about this?

SELECT COL1, COL2, REPLICATE(DATALENGTH(PASSWORD), '*') AS PASSWORD
FROM TABLE


Just kidding !!

Frankly this is a front-end issue and better handled there.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"


You did it reversely

That should be

SELECT COL1, COL2, REPLICATE('*',DATALENGTH(PASSWORD)) AS PASSWORD
FROM TABLE

Though I like your front end advice

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-11 : 04:40:55
quote:
Originally posted by spirit1

don't store passwords in plain text at all.
hash them with MD5 and insert the hash into the db.


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp

You meant to say "encrypt and store"?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-11 : 04:57:11
no i don't mean encrypt and store.

Encryption can be decrypted.
A hash can't. Let's not get into details about MD5 being broken etc...

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-11 : 05:34:47
Thanks. I think I need to read about hash

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-11 : 07:15:55
Thanks Madhi for the correction.

Spirit, the OP doesn't care about how to store password in table he just want to show it as number of asterisks.

Anyway, Anu see if the below links help you for encryption:
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76258&SearchTerms=encrypt[/url]
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61364&SearchTerms=encrypt[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-11 : 07:19:17
true. but i think that he should see the error of his way

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -