Results 1 to 2 of 2

Thread: Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    84

    Question

    I want to save my high score list in a textfile. But I don't want anyone to be able to open it in wordpad and change it. How can I do take save it with "special" character.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Your could encrypt the file and unencrypt it when you want to open it.
    [code]
    'Encrypt/Unencrypt a file
    '
    Option Explicit
    '
    Private Function EncryptFile(sFile As String, iKey As Integer)

    Dim iFake#
    Dim x As String * 1

    Dim lP As Long, z
    Dim intNum#
    intNum = FreeFile

    iFake = Rnd(-1)
    Randomize (iKey)


    lP = 1
    Open sFile For Binary As intNum

    While lP <= LOF(intNum)

    Get #intNum, lP, x

    z = Asc(x) + Int(Rnd * 256)
    If z > 255 Then z = z - 256

    x = Chr(z)

    Put #intNum, lP, x

    lP = lP + 1


    Wend

    Close #intNum

    MsgBox "Your file has been encrypted."

    End Function


    Private Function DecryptFile(sFile As String, iKey As Integer)

    Dim iFake As Integer
    Dim x As String * 1

    Dim lP As Long, z
    Dim intNum#

    intNum = FreeFile

    iFake = Rnd(-1)
    Randomize (iKey)


    lP = 1
    Open sFile For Binary As #intNum

    While lP <= LOF(intNum)

    Get #intNum, lP, x

    z = Asc(x) - Int(Rnd * 256)
    If z < 0 Then z = z + 256

    x = Chr(z)

    Put #intNum, lP, x

    lP = lP + 1

    Wend

    Close #intNum

    MsgBox "Your file has been unencrypted."

    End Function

    ' <<<< Form Event Code >>>>


    Private Sub Command1_Click()

    Call EncryptFile("a:\yourifle.doc", 44)

    End Sub

    Private Sub Command2_Click()

    Call DecryptFile("a:\yourifle.doc", 44)

    End Sub

    [code]

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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