|
-
Nov 12th, 2002, 01:01 PM
#1
Implementing passwords **resolved
The extent of my abilities is saving/reading text to and from a text file but that would defeat the purpose of implementing passwords. Could someone tell me how I can save the password in a more secure file? A simpe sample would be nice. Thanks.
Last edited by leinad31; Dec 20th, 2002 at 06:35 PM.
-
Nov 12th, 2002, 01:03 PM
#2
Frenzied Member
Encrypt the file. Do a search on file encryption, there are infinate examples
-
Nov 12th, 2002, 01:10 PM
#3
I considered that but i thought it would be too much effort if the file is just gonna contain 1 password (8-12 characters) and nothing else. I was hoping for another solution. It doesnt have to be very secure, just as long as it cant be opened with just a text file viewer and is updatable so the password can be changed.
-
Nov 12th, 2002, 01:14 PM
#4
Frenzied Member
Here's an encryption/ Decryption function
VB Code:
'General Declerations
Const Public_Key = "Test178uy"
Const Private_Key = "$45rt8"
Public strDecrypted As String
Public strEncrypted As String
Public Function Crypto(InString As String, PrivateKey As String, PublicKey As String) As String
Dim myIN, myKEY As String, myC As String, myPub As String
Dim KeyList() As Byte
Dim PubList() As Byte
Dim I As Long, J As Long, k As Long
myIN = InString
myKEY = PrivateKey
myPub = PublicKey
ReDim KeyList(Len(myKEY))
ReDim PubList(Len(myPub))
For I = 1 To Len(myKEY)
KeyList(I) = Asc(Mid(myKEY, I, 1))
Next I
For I = 1 To Len(myPub)
PubList(I) = Asc(Mid(myPub, I, 1))
Next I
J = 1
k = 1
For I = 1 To Len(myIN)
myC = myC & Chr((Asc(Mid(myIN, I, 1)) Xor KeyList(J)) Xor PubList(k))
If J = Len(myKEY) Then J = 0
If k = Len(myPub) Then k = 0
J = J + 1
k = k + 1
Next I
Crypto = myC
End Function
Use it like this:
VB Code:
Private Sub Comman1_Click()
strEncryption = Crypto("My Password", Private_Key, Public_Key) 'This will encrypt My Password.
to Decrypt
strDecryption=Crypto(strEncrypted, Private_Key, Public_Key)
MsgBox strDecryption
End Sub
You could save the encrypted username & passwords in a text file..and then call it back or you could save it in the Windows Registry as well...
-
Nov 12th, 2002, 01:28 PM
#5
Guess i'll go with the encrypt/decrypt plan then. Thanks for including the implementation of pub/priv keys in your sample.
-
Dec 17th, 2002, 04:01 AM
#6
mxnmx's example is a basic XOR algorithm, and the public and private key is placed in error there.... that's defenitly not how your supposed to use a public and private key...
Here's how the encryption/decryption SHOULD be with public and private keys:
First of all you use one at the time...
To encrypt, you use the public key, and you are NOT able to decrypt with the public key, ONLY encrypt
To decrypt, you use the private key, and the private key is used for decryption ONLY !
If you wander why ?
Let's say you have a group of friends, and you want to exchange data in a safe way (encryption), you give the public key to your friends, they encrypt the data, send it to a server (for example), and since only you have the private key, only you can decrypt the data. And if you want to send data back, you need their public key(s), and so on...
In the example given there, they are both used when encrypting AND decryption of the string witch is wrong...
In the example, a correct variable name would be, password1 and password2, because that's what it does... it's using 2 passwords to encrypt and decrypt
To prove my point go to this link, and scroll to "Public-Key Encryption"
http://developer.netscape.com/docs/m...n/contents.htm
Last edited by CVMichael; Dec 17th, 2002 at 04:06 AM.
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
|