Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encrypting Field

Status
Not open for further replies.

Grif

MIS
Nov 28, 2001
12
US
How do I encrypt fields in SQL Server?

thanx
 
There is no supported, documented way of doing this.

Check the SQL FAQ at for more information, additional links and some more ideas about SQL Server encryption. You'll have to register at this site.

Outdated copies of the SQL FAQ with much of the same info are available at

Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it if you have time.
 
Microsoft has a simple encrypt/decrypt routine that you can use from VB and ASP. I've used it to encrypt fields before storing them in a SQL Server database. It's so short, I'll post it here.

You pass it the string you wish to encrypt/decrypt and a password. The first time you pass the string it encrypts. Call it again with the same parameters, it decrypts.

Public Function Encrypt(strInput As String, strPassword As String) As String
Dim L As Integer
Dim X As Integer
Dim Char As Integer
' strInput = the string you wish to encrypt or decrypt.
' strPassword = the password with which to encrypt the string.
L = Len(strPassword)
For X = 1 To Len(strInput)
Char = Asc(Mid$(strPassword, (X Mod L) - L * ((X Mod L) = 0), 1))
Mid$(strInput, X, 1) = Chr$(Asc(Mid$(strInput, X, 1)) Xor Char)
Next
Encrypt = strInput
End Function

Brian J. Alves
Email: brian.alves@worldnet.att.net
VB / ASP / Crystal / SQLServer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top