|
-
Nov 19th, 2007, 04:22 PM
#1
Thread Starter
Hyperactive Member
Password encryption question.
Hello all,
I got this code from the forums here, but am not sure where I should place it.
I want so that when a user enters his password it will be like this **** or something.
vb Code:
Public Function RndCrypt(ByVal Str As String, ByVal Password As String) As String
'
' Made by Michael Ciurescu (CVMichael from vbforums.com)
' Original thread: [url]http://www.vbforums.com/showthread.php?t=231798[/url]
'
Dim SK As Long, K As Long
' init randomizer for password
Rnd -1
Randomize Len(Password)
' (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd)) -> makes sure that a
' password like "pass12" does NOT give the same result as the password "sspa12" or "12pass"
' or "1pass2" etc. (or any combination of the same letters)
For K = 1 To Len(Password)
SK = SK + (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd))
Next K
' init randomizer for encryption/decryption
Rnd -1
Randomize SK
' encrypt/decrypt every character using the randomizer
For K = 1 To Len(Str)
Mid$(Str, K, 1) = Chr(Fix(256 * Rnd) Xor Asc(Mid$(Str, K, 1)))
Next K
RndCrypt = Str
End Function
-
Nov 19th, 2007, 05:01 PM
#2
Re: Password encryption question.
 Originally Posted by cfd33
I want so that when a user enters his password it will be like this **** or something.
If you just want to display * instead of the actual password, then click on the textbox, go to the Properties window, and set the PasswordChar to *
-
Nov 19th, 2007, 05:10 PM
#3
Thread Starter
Hyperactive Member
Re: Password encryption question.
CVMichael,
Thank you for your reply.
I am new at this stuff; so please bear with me.
So what exactly does the encryption do? I thought that it would jumble the password characters.
Do I also have to change my database to make the data entered ***? so no one can open the database and see the passwords.
Last edited by cfd33; Nov 19th, 2007 at 05:14 PM.
-
Nov 19th, 2007, 05:13 PM
#4
Lively Member
Re: Password encryption question.
The method you posted would indeed create an encrypted password. But for what you asked, just changing the 'Password Char' in the textboxes properties will give you exactly what you need. You shouldn't have to change anything in your db, as 'masking' the characters in the textbox doesn't affect anything but that particular textbox.
-
Nov 19th, 2007, 05:15 PM
#5
Thread Starter
Hyperactive Member
Re: Password encryption question.
Neato,
Thanks for the reply.
How do I keep people from opening the database and seeing the passwords?
Should I mask them as well in Access?
Also, just for my knowledge; where does the above code go? into the change event, keypress, gotfocus , etc...
-
Nov 19th, 2007, 05:19 PM
#6
Lively Member
Re: Password encryption question.
For that, you'd need to encrypt the file you're saving them to, since using an mdb file doesn't actually encrypt the inputted text, as you'd see if you open it in notepad, and do a text search for a known name that you added.
Creating an encryption/decryption function, much as the one you previously posted would work. You just have to run it each time the database is accessed for record check/record set.
--Which code are you referring to? The encryption? That would go whenever you need to check or set a record. The password char is changed via the actual textboxes properties.
-
Nov 19th, 2007, 05:30 PM
#7
Thread Starter
Hyperactive Member
Re: Password encryption question.
Neato,
I am very new to this encryption thing and right now I am very confused.
So the record check would be when the user enters his password and checks it against the db; is this what you mean?
Wouldnt the password need to be encrypted before the check?
Man, I am so confused. Is there any good tutorials on encryption?
-
Nov 19th, 2007, 05:38 PM
#8
Lively Member
Re: Password encryption question.
So the record check would be when the user enters his password and checks it against the db; is this what you mean?
Yes.
Wouldnt the password need to be encrypted before the check?
You need an encryption and decryption method to properly check it. Meaning that it would be encrypted on 'set' and decrypted to be checked on 'read'.
Is there any good tutorials on encryption?
Google.com
There's also an article on here: http://www.vbforums.com/showthread.php?t=345183
-
Nov 19th, 2007, 05:40 PM
#9
Thread Starter
Hyperactive Member
Re: Password encryption question.
Neato,
Thanks for your assistance. I will check into Google.
-
Nov 19th, 2007, 06:59 PM
#10
Re: Password encryption question.
Or you could store the password hashed in the database, like in this example:
http://vbforums.com/showthread.php?t=438957
-
Nov 19th, 2007, 07:33 PM
#11
Thread Starter
Hyperactive Member
Re: Password encryption question.
CVMichael,
Thanks, I will give that a try!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|