How to Implement Password to Harsh form

Moore71

DEVELOPER
Local time
Today, 07:49
Joined
Jul 14, 2012
Messages
158
Hi,
I got some code for converting text to harsh password but my problem now is how to really implement the code such that when i type anything as password, it should be automatically be converted to harsh text. Here is my code below:


Global g_Enabled As Boolean
Public Const Salt As Long = 803401179

Public Function Encrypt(strIn As String) As String
Dim strChr As String
Dim i As Integer

For i = 1 To Len(strIn)
strChr = strChr & CStr(Asc(Mid(strIn, i, 1)) Xor Salt)
Next i
Encrypt = strChr
End Function

Thank you in advance.
 
Moore71,

I see that plog posted a link to a previous thread that includes code I posted that is very similar to your.

my problem now is how to really implement the code such that when i type anything as password, it should be automatically be converted to harsh text.

Here is how it is typically used:

1) When saving the password you would call the function to hash the password just before it is saved. Not as it is entered by the user.

Example ins an update query using the text Box named txtPassword on the current form

Code:
... Set [UserPassword] = " & Encrypt(Me.txtPassword) & " ...

2) To validate the password you would has (Encrypt) it as you compare it to the save password.

Example:

Code:
If Encrypt(Me.txtPassword) = DLookup("[UserPassword]", "Users", "UserdID=" & Me.UserID) then


Note: It is common that passwords are hashed/encrypted in a manner that can not be revered.
 
Hi,
I got some code for converting text to harsh password but my problem now is how to really implement the code such that when i type anything as password, it should be automatically be converted to harsh text. Here is my code below:


Global g_Enabled As Boolean
Public Const Salt As Long = 803401179

Public Function Encrypt(strIn As String) As String
Dim strChr As String
Dim i As Integer

For i = 1 To Len(strIn)
strChr = strChr & CStr(Asc(Mid(strIn, i, 1)) Xor Salt)
Next i
Encrypt = strChr
End Function

Thank you in advance.

Have you considered in the design of a table you can use a text field and use a MASK to encrypt the password.
 
@Moore: there is a problem with your method. You are XORing an integer with a long. Wonder what's the result.
I propose that you convert the result of Asc to byte then XOR it with a byte Salt. Note that your method is very easy to break.
 
Stevendavis, glad you find this information useful.

The above method is a not he most secure method for encryption. While is will stop most people, it is not the most difficult one to crack.

II have posted an example on my site that shows a the method I use.

See: Encryption
This is an example in 2000 format that shows several example of encryption. The code used in the modules was written by Dermot Balson.
 

Users who are viewing this thread

Back
Top Bottom