Results 1 to 11 of 11

Thread: Password encryption question.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    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:
    1. Public Function RndCrypt(ByVal Str As String, ByVal Password As String) As String
    2.     '
    3.     '  Made by Michael Ciurescu (CVMichael from vbforums.com)
    4.     '  Original thread: [url]http://www.vbforums.com/showthread.php?t=231798[/url]
    5.     '
    6.     Dim SK As Long, K As Long
    7.    
    8.     ' init randomizer for password
    9.     Rnd -1
    10.     Randomize Len(Password)
    11.     ' (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd)) -> makes sure that a
    12.     ' password like "pass12" does NOT give the same result as the password "sspa12" or "12pass"
    13.     ' or "1pass2" etc. (or any combination of the same letters)
    14.    
    15.     For K = 1 To Len(Password)
    16.         SK = SK + (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd))
    17.     Next K
    18.    
    19.     ' init randomizer for encryption/decryption
    20.     Rnd -1
    21.     Randomize SK
    22.    
    23.     ' encrypt/decrypt every character using the randomizer
    24.     For K = 1 To Len(Str)
    25.         Mid$(Str, K, 1) = Chr(Fix(256 * Rnd) Xor Asc(Mid$(Str, K, 1)))
    26.     Next K
    27.    
    28.     RndCrypt = Str
    29. End Function

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Password encryption question.

    Quote 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 *

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    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.

  4. #4
    Lively Member
    Join Date
    Nov 2007
    Location
    Rochester, NY
    Posts
    111

    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    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...

  6. #6
    Lively Member
    Join Date
    Nov 2007
    Location
    Rochester, NY
    Posts
    111

    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.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    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?

  8. #8
    Lively Member
    Join Date
    Nov 2007
    Location
    Rochester, NY
    Posts
    111

    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

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    Re: Password encryption question.

    Neato,

    Thanks for your assistance. I will check into Google.

  10. #10
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    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

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    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
  •  



Click Here to Expand Forum to Full Width