Encrypting a Text File?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
DWolf
Coder
Posts: 10
Joined: Fri Aug 25, 2006 3:58 am

Encrypting a Text File?

Post 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?
RayBritton
Veteran
Posts: 109
Joined: Thu Feb 10, 2005 12:38 pm

Post by RayBritton »

save the file as binary
DWolf
Coder
Posts: 10
Joined: Fri Aug 25, 2006 3:58 am

Post by DWolf »

how do I do that?
ysft12
Newbie
Posts: 5
Joined: Mon Sep 12, 2005 6:30 pm

Post 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

ysft
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: Encrypting a Text File?

Post 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.

*****
Post Reply