Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to Hide a File?

dubidubi Member Posts: 121
I have develped an application that reads data from a
text file.But I want this Text file should not be edited by
the user who runs the application.
It would be better if I could Hide the Text File from the user.

I don't use any Installation Software to Install the application.
Just only the Execution file and the text file is enough
to run the application.

Thanks for your comments.
«1

Comments

  • KoppisKoppis Member Posts: 68
    [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : I have develped an application that reads data from a
    : text file.But I want this Text file should not be edited by
    : the user who runs the application.
    : It would be better if I could Hide the Text File from the user.
    :
    : I don't use any Installation Software to Install the application.
    : Just only the Execution file and the text file is enough
    : to run the application.
    :
    : Thanks for your comments.
    :
    Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.


  • zibadianzibadian Member Posts: 6,349
    : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : I have develped an application that reads data from a
    : : text file.But I want this Text file should not be edited by
    : : the user who runs the application.
    : : It would be better if I could Hide the Text File from the user.
    : :
    : : I don't use any Installation Software to Install the application.
    : : Just only the Execution file and the text file is enough
    : : to run the application.
    : :
    : : Thanks for your comments.
    : :
    : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    :
    :
    :
    You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
  • GaashiusGaashius Member Posts: 349
    : : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : : I have develped an application that reads data from a
    : : : text file.But I want this Text file should not be edited by
    : : : the user who runs the application.
    : : : It would be better if I could Hide the Text File from the user.
    : : :
    : : : I don't use any Installation Software to Install the application.
    : : : Just only the Execution file and the text file is enough
    : : : to run the application.
    : : :
    : : : Thanks for your comments.
    : : :
    : : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    : :
    : :
    : :
    : You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    : A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
    :
    A change of version not makes a file useless. Maybe later versions can read the older files, just by checking the header(if the file has any).
    The XOR encryption solution is easy to implement, so a later version can use that to read older files.

    ****************
    Any questions? Just ask!

    :-) [b][blue]GAASHIUS[/blue][/b] :-)


  • dubidubi Member Posts: 121
    : : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : : I have develped an application that reads data from a
    : : : text file.But I want this Text file should not be edited by
    : : : the user who runs the application.
    : : : It would be better if I could Hide the Text File from the user.
    : : :
    : : : I don't use any Installation Software to Install the application.
    : : : Just only the Execution file and the text file is enough
    : : : to run the application.
    : : :
    : : : Thanks for your comments.
    : : :
    : : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    : :
    : :
    : :
    : You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    : A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
    :

    Thanks for your comments.
    Both of you have the view point of encrypting the file.
    But I just use a notepad to create a text file and the application
    use that text file.
    The pity thing is I don't know how to encrypt a text file.

  • GaashiusGaashius Member Posts: 349
    : : : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : : : I have develped an application that reads data from a
    : : : : text file.But I want this Text file should not be edited by
    : : : : the user who runs the application.
    : : : : It would be better if I could Hide the Text File from the user.
    : : : :
    : : : : I don't use any Installation Software to Install the application.
    : : : : Just only the Execution file and the text file is enough
    : : : : to run the application.
    : : : :
    : : : : Thanks for your comments.
    : : : :
    : : : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    : : :
    : : :
    : : :
    : : You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    : : A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
    : :
    :
    : Thanks for your comments.
    : Both of you have the view point of encrypting the file.
    : But I just use a notepad to create a text file and the application
    : use that text file.
    : The pity thing is I don't know how to encrypt a text file.
    :
    :
    OK, fast example, racing to help you :-)
    [code]
    procedure encryptfile(from:string;to:string);
    var
    s1,s2:file of byte;
    n,m:byte;
    begin
    if fileexists(from) then begin // check if "encryptneed" file exists
    assignfile(s1,from); // open the file needs to be encrypted
    reset(s1);
    assignfile(s2,to); // now open the destination
    rewrite(s2);
    repeat
    read(s1,n); // read from original
    m:=256-n; // encrypt data
    write(s2,m); // write encrypted data to destination
    until EOF(s1);
    close(s2); //close files
    close(s1); //close files
    end;
    end;
    [/code]
    This proc encrypts a file.

    ****************
    Any questions? Just ask!

    :-) [b][blue]GAASHIUS[/blue][/b] :-)


  • dubidubi Member Posts: 121
    : : : : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : : : : I have develped an application that reads data from a
    : : : : : text file.But I want this Text file should not be edited by
    : : : : : the user who runs the application.
    : : : : : It would be better if I could Hide the Text File from the user.
    : : : : :
    : : : : : I don't use any Installation Software to Install the application.
    : : : : : Just only the Execution file and the text file is enough
    : : : : : to run the application.
    : : : : :
    : : : : : Thanks for your comments.
    : : : : :
    : : : : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    : : : :
    : : : :
    : : : :
    : : : You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    : : : A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
    : : :
    : :
    : : Thanks for your comments.
    : : Both of you have the view point of encrypting the file.
    : : But I just use a notepad to create a text file and the application
    : : use that text file.
    : : The pity thing is I don't know how to encrypt a text file.
    : :
    : :
    : OK, fast example, racing to help you :-)
    : [code]
    : procedure encryptfile(from:string;to:string);
    : var
    : s1,s2:file of byte;
    : n,m:byte;
    : begin
    : if fileexists(from) then begin // check if "encryptneed" file exists
    : assignfile(s1,from); // open the file needs to be encrypted
    : reset(s1);
    : assignfile(s2,to); // now open the destination
    : rewrite(s2);
    : repeat
    : read(s1,n); // read from original
    : m:=256-n; // encrypt data
    : write(s2,m); // write encrypted data to destination
    : until EOF(s1);
    : close(s2); //close files
    : close(s1); //close files
    : end;
    : end;
    : [/code]
    : This proc encrypts a file.
    :
    : ****************
    : Any questions? Just ask!
    :
    : :-) [b][blue]GAASHIUS[/blue][/b] :-)
    :
    :
    :

    Thanks a lot.


  • GaashiusGaashius Member Posts: 349
    No problem :-)

    ****************
    Any questions? Just ask!

    :-) [b][blue]GAASHIUS[/blue][/b] :-)


  • zibadianzibadian Member Posts: 6,349
    : : : : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : : : : I have develped an application that reads data from a
    : : : : : text file.But I want this Text file should not be edited by
    : : : : : the user who runs the application.
    : : : : : It would be better if I could Hide the Text File from the user.
    : : : : :
    : : : : : I don't use any Installation Software to Install the application.
    : : : : : Just only the Execution file and the text file is enough
    : : : : : to run the application.
    : : : : :
    : : : : : Thanks for your comments.
    : : : : :
    : : : : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    : : : :
    : : : :
    : : : :
    : : : You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    : : : A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
    : : :
    : :
    : : Thanks for your comments.
    : : Both of you have the view point of encrypting the file.
    : : But I just use a notepad to create a text file and the application
    : : use that text file.
    : : The pity thing is I don't know how to encrypt a text file.
    : :
    : :
    : OK, fast example, racing to help you :-)
    : [code]
    : procedure encryptfile(from:string;to:string);
    : var
    : s1,s2:file of byte;
    : n,m:byte;
    : begin
    : if fileexists(from) then begin // check if "encryptneed" file exists
    : assignfile(s1,from); // open the file needs to be encrypted
    : reset(s1);
    : assignfile(s2,to); // now open the destination
    : rewrite(s2);
    : repeat
    : read(s1,n); // read from original
    : m:=256-n; // encrypt data
    : write(s2,m); // write encrypted data to destination
    : until EOF(s1);
    : close(s2); //close files
    : close(s1); //close files
    : end;
    : end;
    : [/code]
    : This proc encrypts a file.
    :
    : ****************
    : Any questions? Just ask!
    :
    : :-) [b][blue]GAASHIUS[/blue][/b] :-)
    :
    :
    :
    It is better to use a while-do loop instead of a repeat-until loop, because a while-do loop will also work for empty files. Here is the code:
    [code]
    while not eof(s1) do
    begin
    read(s1,n); // read from original
    m:=[red]255[/red]-n; // encrypt data
    write(s2,m); // write encrypted data to destination
    end;
    [/code]
    Also notice that I have changed the constant to 255, because 256-n can produce an integer overflow error if n = 0. A byte has an upper limit of 255.
  • GaashiusGaashius Member Posts: 349
    : : : : : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : : : : : I have develped an application that reads data from a
    : : : : : : text file.But I want this Text file should not be edited by
    : : : : : : the user who runs the application.
    : : : : : : It would be better if I could Hide the Text File from the user.
    : : : : : :
    : : : : : : I don't use any Installation Software to Install the application.
    : : : : : : Just only the Execution file and the text file is enough
    : : : : : : to run the application.
    : : : : : :
    : : : : : : Thanks for your comments.
    : : : : : :
    : : : : : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    : : : : :
    : : : : :
    : : : : :
    : : : : You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    : : : : A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
    : : : :
    : : :
    : : : Thanks for your comments.
    : : : Both of you have the view point of encrypting the file.
    : : : But I just use a notepad to create a text file and the application
    : : : use that text file.
    : : : The pity thing is I don't know how to encrypt a text file.
    : : :
    : : :
    : : OK, fast example, racing to help you :-)
    : : [code]
    : : procedure encryptfile(from:string;to:string);
    : : var
    : : s1,s2:file of byte;
    : : n,m:byte;
    : : begin
    : : if fileexists(from) then begin // check if "encryptneed" file exists
    : : assignfile(s1,from); // open the file needs to be encrypted
    : : reset(s1);
    : : assignfile(s2,to); // now open the destination
    : : rewrite(s2);
    : : repeat
    : : read(s1,n); // read from original
    : : m:=256-n; // encrypt data
    : : write(s2,m); // write encrypted data to destination
    : : until EOF(s1);
    : : close(s2); //close files
    : : close(s1); //close files
    : : end;
    : : end;
    : : [/code]
    : : This proc encrypts a file.
    : :
    : : ****************
    : : Any questions? Just ask!
    : :
    : : :-) [b][blue]GAASHIUS[/blue][/b] :-)
    : :
    : :
    : :
    : It is better to use a while-do loop instead of a repeat-until loop, because a while-do loop will also work for empty files. Here is the code:
    : [code]
    : while not eof(s1) do
    : begin
    : read(s1,n); // read from original
    : m:=[red]255[/red]-n; // encrypt data
    : write(s2,m); // write encrypted data to destination
    : end;
    : [/code]
    : Also notice that I have changed the constant to 255, because 256-n can produce an integer overflow error if n = 0. A byte has an upper limit of 255.
    :
    Sorry for that, and thanks for fixing

    But I can't understand you Zibadian. Why would Dubi encrypt an empty file?

    And also the file-emptiness(sorry, my english) could be checked before the loop. I mean:
    [code]
    if filesize(s1)<>0 then ...
    [/code]

    ****************
    Any questions? Just ask!

    :-) [b][blue]GAASHIUS[/blue][/b] :-)


  • zibadianzibadian Member Posts: 6,349
    : : : : : : [b][red]This message was edited by Koppis at 2005-4-15 4:40:6[/red][/b][hr]
    : : : : : : : I have develped an application that reads data from a
    : : : : : : : text file.But I want this Text file should not be edited by
    : : : : : : : the user who runs the application.
    : : : : : : : It would be better if I could Hide the Text File from the user.
    : : : : : : :
    : : : : : : : I don't use any Installation Software to Install the application.
    : : : : : : : Just only the Execution file and the text file is enough
    : : : : : : : to run the application.
    : : : : : : :
    : : : : : : : Thanks for your comments.
    : : : : : : :
    : : : : : : Maybe I understood wrong, but why don't you just right click the file, and check the hided and read-only boxes. No ship this file with your application. I don't believe there to be any ultimate solution to stop user editing your files, except if you encrypt them. This way users wont be able to know what their changes in the file will do. You can write your own encrypt algorith if you want. Just don't use those basic ones like "add +1 to each character". They are too obvious.
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : You could also include a type of crc-check onto that file. If the user changes it, the program can detect it and not open it or even run itself.
    : : : : : A fine encryption is to XOR it with the executable as key. This is not very obvious, but easy to implement. The problem is that if the version of the program changes the file becomes useless.
    : : : : :
    : : : :
    : : : : Thanks for your comments.
    : : : : Both of you have the view point of encrypting the file.
    : : : : But I just use a notepad to create a text file and the application
    : : : : use that text file.
    : : : : The pity thing is I don't know how to encrypt a text file.
    : : : :
    : : : :
    : : : OK, fast example, racing to help you :-)
    : : : [code]
    : : : procedure encryptfile(from:string;to:string);
    : : : var
    : : : s1,s2:file of byte;
    : : : n,m:byte;
    : : : begin
    : : : if fileexists(from) then begin // check if "encryptneed" file exists
    : : : assignfile(s1,from); // open the file needs to be encrypted
    : : : reset(s1);
    : : : assignfile(s2,to); // now open the destination
    : : : rewrite(s2);
    : : : repeat
    : : : read(s1,n); // read from original
    : : : m:=256-n; // encrypt data
    : : : write(s2,m); // write encrypted data to destination
    : : : until EOF(s1);
    : : : close(s2); //close files
    : : : close(s1); //close files
    : : : end;
    : : : end;
    : : : [/code]
    : : : This proc encrypts a file.
    : : :
    : : : ****************
    : : : Any questions? Just ask!
    : : :
    : : : :-) [b][blue]GAASHIUS[/blue][/b] :-)
    : : :
    : : :
    : : :
    : : It is better to use a while-do loop instead of a repeat-until loop, because a while-do loop will also work for empty files. Here is the code:
    : : [code]
    : : while not eof(s1) do
    : : begin
    : : read(s1,n); // read from original
    : : m:=[red]255[/red]-n; // encrypt data
    : : write(s2,m); // write encrypted data to destination
    : : end;
    : : [/code]
    : : Also notice that I have changed the constant to 255, because 256-n can produce an integer overflow error if n = 0. A byte has an upper limit of 255.
    : :
    : Sorry for that, and thanks for fixing
    :
    : But I can't understand you Zibadian. Why would Dubi encrypt an empty file?
    :
    : And also the file-emptiness(sorry, my english) could be checked before the loop. I mean:
    : [code]
    : if filesize(s1)<>0 then ...
    : [/code]
    :
    : ****************
    : Any questions? Just ask!
    :
    : :-) [b][blue]GAASHIUS[/blue][/b] :-)
    :
    :
    :
    Normally no-one would want to encrypt an empty file, but it could happen that the program opens an empty file by accident. And, yes, it is possible to check if the file is empty before entering a repeat-until loop, but that increases the size of the executable and could be forgotten by mistake; while training one-self in using a while-do loop to read files lessens the chance of making that mistake. You could even use a for-do loop:
    [code]
    if FileSize(s1) > 0 then
    for i := 0 to FileSize(s1)-1 do
    [/code]
    but this increases the number of callsw to FileSize(), which is quite a slow function.
    So from a performance and development standpoint, while-do is preferred in this case.
«1
Sign In or Register to comment.