Results 1 to 6 of 6

Thread: Implementing passwords **resolved

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

  2. #2
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    Encrypt the file. Do a search on file encryption, there are infinate examples

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    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.

  4. #4
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    Here's an encryption/ Decryption function

    VB Code:
    1. 'General Declerations
    2. Const Public_Key = "Test178uy"
    3. Const Private_Key = "$45rt8"
    4. Public strDecrypted As String
    5. Public strEncrypted As String
    6.  
    7. Public Function Crypto(InString As String, PrivateKey As String, PublicKey As String) As String
    8.     Dim myIN, myKEY As String, myC As String, myPub As String
    9.     Dim KeyList() As Byte
    10.     Dim PubList() As Byte
    11.     Dim I As Long, J As Long, k As Long
    12.    
    13.     myIN = InString
    14.     myKEY = PrivateKey
    15.     myPub = PublicKey
    16.    
    17.     ReDim KeyList(Len(myKEY))
    18.     ReDim PubList(Len(myPub))
    19.    
    20.     For I = 1 To Len(myKEY)
    21.         KeyList(I) = Asc(Mid(myKEY, I, 1))
    22.     Next I
    23.    
    24.     For I = 1 To Len(myPub)
    25.         PubList(I) = Asc(Mid(myPub, I, 1))
    26.     Next I
    27.    
    28.    
    29.     J = 1
    30.     k = 1
    31.     For I = 1 To Len(myIN)
    32.         myC = myC & Chr((Asc(Mid(myIN, I, 1)) Xor KeyList(J)) Xor PubList(k))
    33.         If J = Len(myKEY) Then J = 0
    34.         If k = Len(myPub) Then k = 0
    35.         J = J + 1
    36.         k = k + 1
    37.     Next I
    38.    
    39.     Crypto = myC
    40. End Function

    Use it like this:
    VB Code:
    1. Private Sub Comman1_Click()
    2. strEncryption = Crypto("My Password", Private_Key, Public_Key) 'This will encrypt My Password.
    3. to Decrypt
    4. strDecryption=Crypto(strEncrypted, Private_Key, Public_Key)
    5. MsgBox strDecryption
    6. 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...
    Can't Remember Birthdays or Important Dates- Never Miss any Important Date(s)

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Guess i'll go with the encrypt/decrypt plan then. Thanks for including the implementation of pub/priv keys in your sample.

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    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
  •  



Click Here to Expand Forum to Full Width