Results 1 to 4 of 4

Thread: Binary file creation

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Cleveland, OH
    Posts
    12
    I've been going through several tutorials on different methods of File Access, Text, Random, Binary, etc. I'm wanting to save the users passwords in a file that someone can't easily view. I've also seen several different methods on encryption. My first thought was that binary mode was a way to actually create, read and write to a binary file, not easily viewed in a text editor. But it seems just to be the method by which the data is writtrn and retrieved, it still being an actual text file.

    Is there a way to create a file that cannot be edited or viewed easily, and the data encrypted, or do I use the Text, Random, or Binary method and encrypt and decrypt the passwords.

    Any thoughts on this would be greatly appreciated.
    Shawn Martin
    Ecopic Corporation
    [email protected] - work
    [email protected] - home

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177

    Talking

    You need to create an interface that will encrypt and decrypt your data. The trick is writing a function that prevents that file from being opened without using the interface. Your interface should store the encrypted data not just the text.
    212 will lead you to the truth

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    This is a function for some simple encryption/decryption.
    Code:
    Function Crypt(Data As String) As String
        Dim oneByte As String ' a swap variable
        Dim Output As String  ' the output
    
        For i = 1 To Len(Data) 'loop trough all the bytes
            oneByte = Right(Left(Data, i), 1) ' get a byte
            oneByte = Chr((Int(Asc(oneByte)) Xor 152)) ' encrypt the byte
            Output = Output & oneByte ' add it to the output
        Next
        
        Crypt = Output ' return the encrypted or decrypted data
    End Function
    This is one function that handles encryption and decryption. If you will give it a string, it will return it encrypted. If you give it an encrypted string, it will return it decrypted.

    [Edited by oetje on 10-03-2000 at 03:33 PM]
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  4. #4
    Lively Member
    Join Date
    Sep 2000
    Location
    NC, USA
    Posts
    102

    Lightbulb Well, I guess it depends on how secure you need to be

    I mean if it didn't have to be extremely complex or secure you could just make up an algorithm for the characters of the password. All numbers and letters fall between ascii values of 48 - 57, 65 - 90 or 97 - 122 so you could just perform some math on each character to change its value to an unreadable one that only you knew how to calculate. i.e.

    Code:
    Option Explicit
    Dim ePassword As String
    Dim dPassword As String
    Private Sub cmdDecrypt_Click()
        Dim iCount As Integer
        dPassword = ""
        For iCount = 1 To Len(ePassword)
            dPassword = dPassword & Chr((Asc(Mid(ePassword, iCount, 1)) + (Len(ePassword) + (iCount * 2))) / 2)
        Next
        MsgBox dPassword, vbOKOnly, "Decrypted Password"
    End Sub
    
    Private Sub cmdEncrypt_Click()
        Dim iCount As Integer
        ePassword = ""
        For iCount = 1 To Len(txtInput.Text)
            ePassword = ePassword & Chr((Asc(Mid(txtInput.Text, iCount, 1)) * 2) - (Len(txtInput.Text) + (iCount * 2)))
        Next
        txtInput.Text = ""
        MsgBox ePassword, vbOKOnly, "Encrypted Password"
    End Sub
    Try that out. It would convert the password to an unreadable ascii value that you could store in a file and then recalculate to compare. You may want to be a little more creative and alter the length though.

    Hope that helps,
    KillemAll


    Just saw oetje's post

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