Page 1 of 1

Encrypting a Text File?

Posted: Sat Aug 26, 2006 4:58 am
by DWolf
When you save a QBASIC Program to a text file and store variables in it, is there anyway to encrypt the numbers so people using the program can't alter the variables?

Posted: Sat Aug 26, 2006 6:03 am
by RayBritton
save the file as binary

Posted: Sat Aug 26, 2006 6:24 am
by DWolf
how do I do that?

Posted: Sat Aug 26, 2006 12:21 pm
by ysft12
to put data in the file:

Code: Select all

data$ = "test"

OPEN "file.dat" FOR BINARY AS #1
  PUT #1, , data$
CLOSE

to get data from the file:

Code: Select all

DIM getd AS STRING * 10

OPEN "file.dat" FOR BINARY AS #1
  GET #1, , getd
  PRINT getd
CLOSE


Re: Encrypting a Text File?

Posted: Sun Aug 27, 2006 1:08 am
by moneo
DWolf wrote:When you save a QBASIC Program to a text file and store variables in it, is there anyway to encrypt the numbers so people using the program can't alter the variables?
I think you guys are missing DWolf's point. His concern is that the user of the program can load the source file into QBasic and using the editor can change variables before running the program.

You can write out the program in binary or you can encrypt it, but that means that YOU have to be there to unscramble/decrypt it so it can be run by the user. Not very practical.

My suggestion is to compile the program to an EXE file. Now anybody can run the EXE independently, and there is no way they can "monkey" with any variables or any code. That's the beauty of an EXE file.

*****