Unix Technical Forum

encrypt(string) Question!!

This is a discussion on encrypt(string) Question!! within the SQL Server forums, part of the Microsoft SQL Server category; --> SQL Server 2000: ################################################## ###### I run the following as a normal query from Analyzer: ################################################## ###### SELECT encrypt(user_password) ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 05:41 AM
Russ Reynolds
 
Posts: n/a
Default encrypt(string) Question!!

SQL Server 2000:

################################################## ######
I run the following as a normal query from Analyzer:
################################################## ######

SELECT encrypt(user_password) FROM emp WHERE user_id = 1

################################################## #######
I run the following query from inside a stored proc:
################################################## #######

SELECT encrypt(user_password) FROM emp WHERE user_id = 1

################################################## #######
Question????
################################################## #######

If the data inside the emp table does not change, how can these two
queries return different values?

Any help would be much appreciated!

thanks,
Russ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 05:41 AM
James Goodwin
 
Posts: n/a
Default Re: encrypt(string) Question!!

> SELECT encrypt(user_password) FROM emp WHERE user_id = 1
>
> SELECT encrypt(user_password) FROM emp WHERE user_id = 1


>
> If the data inside the emp table does not change, how can these two
> queries return different values?


They return different values because the encrypt function 'salts' the data
to prevent someone from just encrypting a bunch of stuff to figure out the
other data in the table.

The Unix crypt function used to do this by putting two random characters on
the front of the data string and also on the front of the encryption string
using the 'salt' as part of the key.

Regards,
Jim



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 05:41 AM
David Portas
 
Posts: n/a
Default Re: encrypt(string) Question!!

In addition to James's reply, note that the Encrypt function is undocumented
so its behaviour can change between versions of the product. Don't rely on
it in production code. Generate a password hash client-side would be my
suggestion.

--
David Portas
SQL Server MVP
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 05:41 AM
Greg D. Moore \(Strider\)
 
Posts: n/a
Default Re: encrypt(string) Question!!


"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:0eadncyJC6oF1hzcRVn-tg@giganews.com...
> In addition to James's reply, note that the Encrypt function is

undocumented
> so its behaviour can change between versions of the product. Don't rely on
> it in production code. Generate a password hash client-side would be my
> suggestion.
>


And in the at least one case I looked at, trivial to decrypt.


> --
> David Portas
> SQL Server MVP
> --
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:06 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com