Results 1 to 19 of 19

Thread: [RESOLVED] Save in Access but encrypted

  1. #1

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Resolved [RESOLVED] Save in Access but encrypted

    I posted in this thread but I think i will not get answer anymore because it is already resolved so i open up a thread for my query.

    I find the code of CVMichael great and want to use it. Here is my question.
    I have a form for password maintenance. I want to use your code in such a way that when the user create a new user and password the password will be save in ACCESS but in an encrypted form. In my log in form the user will type the password and compare the typed password against the saved and encrypted password. Is this possible with your code? If it is I appreciate it very much if you could show me how. thanks!
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  2. #2

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Save in Access but encrypted

    Anyone knows how to do it?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  3. #3
    Fanatic Member mateo107's Avatar
    Join Date
    Jan 2005
    Posts
    547

    Re: Save in Access but encrypted

    well, you could make your own type of encryption / decription built into your vb program...

    I mean, even something simple like, lets say this:

    User enters password of "password" into a textbox...to create or store the password in access:

    you then "add your encryption", in the VB program,

    you could do something silly even, like reverse the letters, or something, or reverse and add numbers in between...
    then you'd store THAT into the database, so, you'd store something like:
    d1r2o3w4s5s6a7p8

    Since Access would show the password as "d1r2o3w4s5s6a7p8", you'd just need to make sure to hard-code your "decryption" into your VB application as well...

    so before checking the "password" string, you'd have to decrypt it, and then check THAT password against the currently entered password.

    I know this is not super hard-core, but maybe that'll get the ideas kickin'?


    -Matthew-

  4. #4
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Save in Access but encrypted

    simple. Let me give you an example. Let's say the user enters the password "VbForum" very first time. so you will encrypt using the CVMichael code. the CVMichael code will give you the encrypted password as "½]{-®ã%‚v&bü²¯Mê~‘´åw~¥-ˆÑYCðܲEí’~gœ0Î>pÛÆï". so you will store this password in database. Next time the user tries to login your application. let's say the user enters the password "something". encrypt this password again and compare that with already existing encrypted password which is stored in database. if both are same then allow the user to login else notify the user that invalid password.

    That's it.

    I hope this helps.
    CS

  5. #5

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Save in Access but encrypted

    cssriraman I'm sorry but how?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  6. #6

  7. #7
    Fanatic Member mateo107's Avatar
    Join Date
    Jan 2005
    Posts
    547

    Re: Save in Access but encrypted

    personally, i just set the mask to "password" and forget about it... if its in an password protected database, i'm pretty confident that my E/U's aren't going to hack the dbase password at the chance to just get data from the dbase...

    if they were to do that, then they can just look at the source data anyway, with no need for my apps.


    -Matthew-

  8. #8
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Save in Access but encrypted

    VB Code:
    1. Option Explicit
    2.  
    3. Public Function RndCrypt(ByVal Str As String, ByVal Password As String) As String
    4.     '  Made by Michael Ciurescu (CVMichael from vbforums.com)
    5.     '  Original thread: [url]http://www.vbforums.com/showthread.php?t=231798[/url]
    6.     Dim SK As Long, K As Long
    7.     ' init randomizer for password
    8.     Rnd -1
    9.     Randomize Len(Password)
    10.     ' (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd)) -> makes sure that a
    11.     ' password like "pass12" does NOT give the same result as the password "sspa12" or "12pass"
    12.     ' or "1pass2" etc. (or any combination of the same letters)
    13.     For K = 1 To Len(Password)
    14.         SK = SK + (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd))
    15.     Next K
    16.     ' init randomizer for encryption/decryption
    17.     Rnd -1
    18.     Randomize SK
    19.     ' encrypt/decrypt every character using the randomizer
    20.     For K = 1 To Len(Str)
    21.         Mid$(Str, K, 1) = Chr(Fix(256 * Rnd) Xor Asc(Mid$(Str, K, 1)))
    22.     Next K
    23.     RndCrypt = Str
    24. End Function
    25.  
    26. Public Function EncryptString(ByVal Str As String)
    27.     Dim EncStr As String
    28.  
    29.     ' some string to encrypt
    30.     Str = "VbForum"
    31.  
    32.     ' make the string 50 characters long
    33.     Str = Str & String(50 - Len(Str), 0)
    34.  
    35.     ' encrypt the string
    36.     EncStr = RndCrypt(Str, "my password")
    37.  
    38.     'Here you have a encrypted form of the password entered by user.
    39.     EncryptString = EncStr
    40. End Function
    41.  
    42. Sub Main()
    43.     'Write the code to save the password entered by user which is encrypted to database
    44.     'once this is done ...
    45.     'This needs to be done for the first time the user enters the password / when creating the login.
    46.     'After that you need to compare the stored password with the password entered by user. That's it.
    47.  
    48. End Sub
    49.  
    50. 'In your login form
    51. Private Sub cmdOK_Click()
    52.     Dim EncryPass As String
    53.     'Let's say the user entered the password in a text box txtPassword.
    54.     'First encrypt the password entered by user in txtPassword
    55.     EncryPass = EncryptString(txtpassword.Text)
    56.     'Read the actual password stored in database and compare it with this encrypted password
    57.     'if you want store in variable Encrypted_Password_From_Database
    58.     If EncryPass = Encrypted_Password_From_Database Then
    59.         Debug.Print "Password is correct... The user can be allowed."
    60.     Else
    61.         Debug.Print "Password is incorrect... The access to the user denied."
    62.     End If
    63. End Sub
    I hope this helps.
    CS

  9. #9
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Save in Access but encrypted


  10. #10

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Save in Access but encrypted

    Quote Originally Posted by MartinLiss
    Why do you need to encrypt something in a database? If you password the database (or table) I don't think anyone will be able to read it.
    For tighter security i guess.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Save in Access but encrypted

    Quote Originally Posted by MartinLiss
    Why do you need to encrypt something in a database? If you password the database (or table) I don't think anyone will be able to read it.
    If it's an access database, the encryption of the password is a joke - it took me 15 minutes the first time to figure out the method they use, and another 15 minutes to write a nice program to return the decrypted password. (No, I'm not posting the code. )

    Personally I use Blowfish if I need strong encryption - it's public domain, open source and very strong (because it's open source). If I need something quick and dirty and not government strength I just XOR the bytes with something - preferably something a bit esoteric.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  12. #12

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Save in Access but encrypted

    I just would like to have a routine where the password created by the user will be saved in my table as encrypted.
    And the same encrypted password will be decrypted to match the password entered by the user in the login form.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  13. #13
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Save in Access but encrypted

    Quote Originally Posted by Simply Me
    I just would like to have a routine where the password created by the user will be saved in my table as encrypted.
    And the same encrypted password will be decrypted to match the password entered by the user in the login form.
    use it like this:
    cmdEnc(strDbPass)
    cmdDec(strDbPass)

    VB Code:
    1. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    2. ' PUBLIC FUNCTION: DECRYPT STRING
    3. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    4. Public Function cmdDec(ByVal strDec As String) As String
    5.     Dim sinp, sout, sc, nc, p
    6.         sinp = strDec
    7.         sout = ""
    8.    
    9.         For p = 1 To Len(sinp) Step 1
    10.             sc = Mid(sinp, p, 1)
    11.             nc = Asc(sc) - 3
    12.             sout = sout + Chr(nc)
    13.         Next p
    14.    
    15.         cmdDec = sout
    16. End Function
    17.  
    18. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    19. ' PUBLIC FUNCTION: ENCRYPT STRING
    20. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    21. Public Function cmdEnc(ByVal strEnc As String) As String
    22.     Dim sinp, sout, sc, nc, p
    23.         sinp = strEnc
    24.         sout = ""
    25.    
    26.         For p = 1 To Len(sinp) Step 1
    27.             sc = Mid(sinp, p, 1)
    28.             nc = Asc(sc) + 3
    29.             sout = sout + Chr(nc)
    30.         Next p
    31.    
    32.         cmdEnc = sout
    33. End Function

  14. #14

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Save in Access but encrypted

    I'll try it rory. Thanks again. be back after testing it.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  15. #15
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Save in Access but encrypted

    Its not great encryption or anything, and its on the web so its not exactly private .. but its just another thing to slow them down .. also I use the lock function on the database which means you cant just manually open it in Access unless you know how to convert it back, and i name it a .dll instead of .mdb.

  16. #16

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Save in Access but encrypted

    interesting. how did u do it?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  17. #17
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Save in Access but encrypted

    Its all there in that thread,

    Create the database within the program, which creates it with the encrypted password, then lock the database on close connection, and unlock on opening of connection. Also when opening the dataabase connection you would decrupt the password. So its 2 things, encrypt password and lock the database .. the lock basically changes the headers and encrypts the new header so MS Access wont recognise the file as valid. Then the program has to decrypt the headers back to normal.

  18. #18

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: Save in Access but encrypted

    Quote Originally Posted by rory
    Its all there in that thread,
    where is the thread?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  19. #19
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Save in Access but encrypted

    Quote Originally Posted by Simply Me
    where is the thread?
    http://www.vbforums.com/showthread.p...11#post2469211

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