What is the encryption function of mssql

Posted on 2006-03-21
Medium Priority
Last Modified: 2008-02-01
I am new to Mssql, I want to know how can I encrypt data according to different algorithm such as md5 and sha1.
In Mysql, I usually use sha1() or md5().
What are the similar functions in Mssql?
Thank you.

Question by:michtsoi
  • 4
  • 3
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16253829
If we are talking about SQL Server 2000, you are out of luck.

Also, the following questions are considered abandonded, please attend to them:
1 12/14/2005 500 PHP forum (Discus, vBulletin) Urgent  Open PHP
2 01/26/2006 500 Random number generation case study prob...  Open Microsoft SQL Server
3 01/27/2006 200 mssql problem about assigning consecutiv...  Open Microsoft SQL Server
4 02/21/2006 500 Cannot display nvarchar data from MSSQL ...  Open PHP
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 16253852
There are no such functions in sql server 2000, there are 2 functions, Pwdencrypt and pwdcompare. These are are internal, undocumented functions that SQL Server uses to manage passwords. Pwdencrypt uses a one-way hash that takes a clear string and returns an encrypted version of that string. Pwdcompare compares an unencrypted string to its encrypted representation to see whether they match. Microsoft cautions against using undocumented internal features, but sometimes people just can’t resist. With that said, yes, there is an undocumented, relatively unknown way to make strings encrypted with the SQL Server 6.5 version of pwdencrypt work with the SQL Server 7.0 version of pwdcompare. . . .


Author Comment

ID: 16253864
Then I am super unlucky that my company is still using Mssql 7.0.
As I know there is no user define function in Mssql 7.0, so am I need to implement a stored procedure to encrypt data by myself?

For those abandoned question, I cannot find an appropriate answer for my question.
1. I want to close it but I don't know how to do that.
2. No appropriate answer and I implement my own solution by myself. My reply is the last one.
3. Same as 2
4. I find the answer, although it is not a good one and even a bit werid, from another website and I share it to experts exchange. No   one can suggest to me a better answer.

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.


Author Comment

ID: 16253891
Hi anneshattinqal,

My company is hosting 2 web sites, 1 of them uses Asp and Mssql and the other one uses php and mssql.
I want to united the data encryption of both site by using the same algorithm.

I have sha1 function in php, Mysql and javascript, but I don't have sha1 function in Mssql and Asp.

For example:
(Before encryption)                      (After encrtption)
Michael                         -->          f8c38b2167c0ab6d7c720e47c2139428d77d8b6a

If anyone can tell me how to achieve this result in Mssql and Asp, I will raise the point to 500 and assign to them.
Thank you very much.
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16253912
>>I cannot find an appropriate answer for my question.<<
See here from the EE Help:

Nobody answered my question. What do I do?

I answered my question myself. What do I do?
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16253919
The best you can do with SQL Server 7:
Undocumented Encrypt and Decrypt Functions in SQL Server 7.0

As far as ASP is concerned you will have to either write or purchase a component.
LVL 75

Accepted Solution

Anthony Perkins earned 1000 total points
ID: 16253936
Here are some free components:

Author Comment

ID: 16254663
Thank you acperkins.
The xpcrypt you introduced to me is so nice.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question