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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encryption of password

Status
Not open for further replies.

BenjaminLim

IS-IT--Management
May 24, 2000
73
GB
Hi,

Please advice what are the synthax to encrypt password & store them in the Oracle database still encrpyted.

Please advice. Thanks.

Regards
Benjamin
 
I use the following code to encrypt and decrypt text strings. I then save them into the registry but you can save it into your DB in a text field. Use your encrypted string against this same function using exactly the same key and it will decrypt it.

Private Function EncDec(byval strString As String) As String
Dim Key As String
Dim Counter1 As Integer
Dim KeyChar As Long
Dim StringChar As Long
Dim CryptedChar As Long
Dim CryptedString As String
Dim Location As Integer

On Error GoTo EncDec_Error
Key = "This is your key. I use a bunch of random characters but you can use whatever you want."
CryptedString = ""
For Counter1 = 1 To Len(strString)
Location = (Counter1 Mod Len(Key)) + 1
KeyChar = Asc(Mid$(Key, Location, 1))
StringChar = Asc(Mid$(strString, Counter1, 1))
CryptedChar = StringChar Xor KeyChar
If CryptedChar = 0 Then
CryptedChar = StringChar
End If
CryptedString = CryptedString & Chr$(CryptedChar)
Next Counter1
EncDec = CryptedString
Exit Function

EncDec_Error:
If Err.Number <> 0 Then
LogError Err.Number, &quot;EncDec_Error - &quot; & Err.Description
End If
End Function
 
The latest release of Oracle allows you to use encrypted tablespaces -- set up one specifically for holding your password table so that the performance penalty (of encrypting and decrypting) doesn't affect the other tables in your application.

If you want a top-shelf encryption algorithm -- visit Bruce Schneier has made his Twofish algorithm publicly available. It was a finalist in the NIST Advanced Encryption Standard competition (AES will replace DES, which is now worthless). He has source code in C, Visual Basic, and Java available.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top