Results 1 to 2 of 2

Thread: text encryption/decryption?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    I'm developing an application which will read information from a text file. There will be no writing to the file, just reading..

    I don't want the end user to be able to read the information in the text file directly.. I had heard that it is possible to somehow decrypt the text and at the same time, my application can still read the text file...

    What is the easiest way to accomplish this? Any help or guidance to the right resources would be appreciated..

    Dan

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To Encrypt The File:

    Code:
    code = InputBox("Enter Encryption Code", , 1)
    If code = "" Then Exit Sub  'if Cancel chosen, exit sub
    charsInFile% = Len(txtNote.Text) 'find string length
    Open CommonDialog1.FileName For Output As #1 'open file
    For i% = 1 To charsInFile%  'for each character in file
    letter$ = Mid(txtNote.Text, i%, 1) 'read next char
    'convert to number w/ Asc, then use Xor to encrypt
    Print #1, Asc(letter$) Xor code; 'and save in file
    Next i%
    Close #1                'close file when finished
    To Decrypt It:

    Code:
    code = InputBox("Enter encryption code", , 1)
    If code = "" Then Exit Sub 'if Cancel chosen, exit sub
    Open CommonDialog1.FileName For Input As #1 'open 
    decrypt$ = ""   'initialize string for decryption
    Do Until EOF(1)         'until end of file reached
    Input #1, Number&   'read encrypted numbers
    e$ = Chr$(Number& Xor code) 'convert with Xor
    decrypt$ = decrypt$ & e$    'and build string
    Loop
    txtNote.Text = decrypt$ 
    End If
    There May Be Some Mistakes But This are the basics.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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