|
-
May 14th, 2006, 05:40 AM
#1
Thread Starter
PowerPoster
[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!
-
May 14th, 2006, 06:13 AM
#2
Thread Starter
PowerPoster
Re: Save in Access but encrypted
Anyone knows how to do it?
-
May 14th, 2006, 07:16 AM
#3
Fanatic Member
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'?
-
May 14th, 2006, 07:22 AM
#4
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.
-
May 14th, 2006, 08:23 AM
#5
Thread Starter
PowerPoster
Re: Save in Access but encrypted
cssriraman I'm sorry but how?
-
May 14th, 2006, 08:42 AM
#6
Re: Save in Access but encrypted
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.
-
May 14th, 2006, 08:52 AM
#7
Fanatic Member
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.
-
May 14th, 2006, 08:52 AM
#8
Re: Save in Access but encrypted
VB Code:
Option Explicit
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
Public Function EncryptString(ByVal Str As String)
Dim EncStr As String
' some string to encrypt
Str = "VbForum"
' make the string 50 characters long
Str = Str & String(50 - Len(Str), 0)
' encrypt the string
EncStr = RndCrypt(Str, "my password")
'Here you have a encrypted form of the password entered by user.
EncryptString = EncStr
End Function
Sub Main()
'Write the code to save the password entered by user which is encrypted to database
'once this is done ...
'This needs to be done for the first time the user enters the password / when creating the login.
'After that you need to compare the stored password with the password entered by user. That's it.
End Sub
'In your login form
Private Sub cmdOK_Click()
Dim EncryPass As String
'Let's say the user entered the password in a text box txtPassword.
'First encrypt the password entered by user in txtPassword
EncryPass = EncryptString(txtpassword.Text)
'Read the actual password stored in database and compare it with this encrypted password
'if you want store in variable Encrypted_Password_From_Database
If EncryPass = Encrypted_Password_From_Database Then
Debug.Print "Password is correct... The user can be allowed."
Else
Debug.Print "Password is incorrect... The access to the user denied."
End If
End Sub
I hope this helps.
-
May 14th, 2006, 09:12 AM
#9
PowerPoster
Re: Save in Access but encrypted
-
May 14th, 2006, 09:50 AM
#10
Thread Starter
PowerPoster
Re: Save in Access but encrypted
 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.
-
May 14th, 2006, 10:52 PM
#11
Re: Save in Access but encrypted
 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
-
May 15th, 2006, 03:08 AM
#12
Thread Starter
PowerPoster
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.
-
May 15th, 2006, 03:13 AM
#13
PowerPoster
Re: Save in Access but encrypted
 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:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' PUBLIC FUNCTION: DECRYPT STRING
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function cmdDec(ByVal strDec As String) As String
Dim sinp, sout, sc, nc, p
sinp = strDec
sout = ""
For p = 1 To Len(sinp) Step 1
sc = Mid(sinp, p, 1)
nc = Asc(sc) - 3
sout = sout + Chr(nc)
Next p
cmdDec = sout
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' PUBLIC FUNCTION: ENCRYPT STRING
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function cmdEnc(ByVal strEnc As String) As String
Dim sinp, sout, sc, nc, p
sinp = strEnc
sout = ""
For p = 1 To Len(sinp) Step 1
sc = Mid(sinp, p, 1)
nc = Asc(sc) + 3
sout = sout + Chr(nc)
Next p
cmdEnc = sout
End Function
-
May 15th, 2006, 04:01 AM
#14
Thread Starter
PowerPoster
Re: Save in Access but encrypted
I'll try it rory. Thanks again. be back after testing it.
-
May 15th, 2006, 04:04 AM
#15
PowerPoster
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.
-
May 15th, 2006, 04:39 AM
#16
Thread Starter
PowerPoster
Re: Save in Access but encrypted
interesting. how did u do it?
-
May 15th, 2006, 04:51 AM
#17
PowerPoster
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.
-
May 15th, 2006, 04:58 AM
#18
Thread Starter
PowerPoster
Re: Save in Access but encrypted
 Originally Posted by rory
Its all there in that thread,
where is the thread?
-
May 15th, 2006, 05:02 AM
#19
PowerPoster
Re: Save in Access but encrypted
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
|