I want to achive that people don't use my program by just re-editing the
inifile and not by using my program. This is also to protect against piracy.
Hans
Looks like the guy that made TCryptIni just added crypting of the values and
not the keys. I wanted to encrypt every bit of the ini file. Totally
unreadable.
But hiss way will also do the trick. Noone will be able to pirate the
program with a notepad.
I don't want to pay $50 for something this basic, so I will just make my own
TCryptIni inherited from TIniFile. The encrypting doesn't need to be like
1024 bit or something like that, just hard enough so that a notepad won't do
the trick.
About the CRC routines, I'm always interrested in learning new stuff, so
bring it on :)
Thanks!
Hans
"Cristian Nicola" <wh...@dahas.ro> wrote in message
news:90jjas$h9...@bornews.inprise.com...
> I don't want to pay $50 for something this basic, so I will just make my own
> TCryptIni inherited from TIniFile. The encrypting doesn't need to be like
> 1024 bit or something like that, just hard enough so that a notepad won't do
> the trick.
For a simple approach, look at the algorithm used here:
http://www.efg2.com/Lab/ImageProcessing/CryptImage.htm
For a variety of other approaches:
http://www.efg2.com/Lab/Library/Delphi/MathFunctions/Cryptography.htm
> About the CRC routines, I'm always interrested in learning new stuff, so
> bring it on :)
After closing the INI file, one simple approach might be to CRC the whole
file (excluding any CRC line). Then re-open the INI file and insert a
CRC value. Later, you could re-CRC the whole file (ignoring the CRC
line that you inserted). If someone tampers with the file, the CRC will
change. If someone tampers with the CRC value, the computed
CRC from the file won't match. The "average" person won't know
how to modify the file and the CRC to match. This will at least
keep "honest people" honest.
Here's some CRC info:
http://www.efg2.com/Lab/Mathematics/CRC.htm
http://www.efg2.com/Lab/Mathematics/FileCheck.htm
--
efg
Earl F. Glynn E-mail: ef...@efg2.com
Overland Park, KS USA
efg's Computer Lab: http://www.efg2.com/Lab
Mirror: http://homepages.borland.com/efg2lab/Default.htm
Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
The idea of using ini file is that it is easy to use the component provided.
But if you have a better way, I would be greatful
Hans
"Rene Tschaggelar" <tscha...@dplanet.ch> wrote in message
news:3A2D6BAF...@dplanet.ch...
>Thanks Cristian,
>
>Looks like the guy that made TCryptIni just added crypting of the values
>and not the keys. I wanted to encrypt every bit of the ini file. Totally
>unreadable.
So basically you want to do this :
reading :
- uncrypt the (crypted).ini file to a temp. file
- use the normal routines to read the values in that file
(- delete the temp file)
writing:
(- create the temp file)
- crypt the temp file to the crypted .ini file
- delete the temp file
With this approach you can just use any component that allows complete file
encryption.
Breyten
--
Breyten J. Ernsting (ICQ: 1760075) http://www.bje.nu/
"Ga nooit naar de avondwinkel als je teveel hebt geblowt!"
Firma Onkruid - Snack
TParamrec=record
fontcolor:TColor;
maxsize:integer;
formcaption:string[50];
{etc}
end;
...
params:TParamrec;
f:file of TParamrec;
....
{save file}
with params do
begin
fontcolor:=font.color;
formcaption:=caption;
maxsize:=strtoint(edit1.text);
{etc}
end;
assignfile(f,extractfilepath(application.exename)+'Params');
rewrite(f);
write(f,params);
closefile(f);
Load is logical inverse of this. If file doesn't exist at load time, you
can initialize with default values. Load and Save can be in Initialization
and Finalization sections respectively.
_________________________
Gary
http://www.delphiforfun.org
_________________________
"Hans Fandsen" <ultra...@usa.net> wrote in message
news:3a2d6cff_1@dnews...
Ini := TMemIniFile.Create(''); // don't supply a file name to load, is
empty.
// put the code to read in your encrypted file and convert to a standard
INI in a TStringList object.
Ini.SetStrings(DecryptedStringList);
// Now use the Ini object to read and write your values.
// .....
// At the end.
Ini.GetStrings(ToBeEncryptedStringList);
// put the code to encrypt the TStringList and save to a file.
Ini.Free;
Paul Moorcroft
If the location has to independent, a crypted ini file is propably the best.
If the location can be fixed (lacking updateability of the app) just
write the values in series as binary.
Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
this should work for you.
procedure NewOrientation(FHandle: HDC; NewOrientation: Byte);
var
ActPrinter : String;
DevMode : PDeviceMode;
SubDevMode : TDeviceMode;
PrinterH : THandle;
DeviceMode : THandle;
begin
ActPrinter := Printer.Printers[Printer.PrinterIndex];
If Pos('an',ActPrinter) <> 0 then
Delete(ActPrinter,Pos('an',ActPrinter)-1,Length (ActPrinter)) else if
Pos('on',ActPrinter) <> 0 then
Delete(ActPrinter,Pos('on',ActPrinter)-1,Length(ActPrinter));
OpenPrinter(PChar(ActPrinter),PrinterH,nil);
DeviceMode := GlobalAlloc(GHND,DocumentProperties(0, PrinterH,
PChar(ActPrinter), SubDevMode, SubDevMode, 0));
if DeviceMode <> 0 then
begin
DevMode := GlobalLock(DeviceMode);
DocumentProperties(0, PrinterH, PChar(ActPrinter), DevMode^,
DevMode^, DM_OUT_BUFFER);
case NewOrientation of
0: DevMode.dmOrientation := DMORIENT_PORTRAIT;
1: DevMode.dmOrientation := DMORIENT_LANDSCAPE;
end;
DevMode.dmFields := DevMode.dmFields or DevMode.dmOrientation;
if EndPage(FHandle) <= 0 then
ShowMessage('error');
ResetDC(FHandle,DevMode^);
GlobalUnlock(DeviceMode);
GlobalFree(DeviceMode);
end;
end;
procedure StartPrinting;
begin
Printer.Orientation := poPortrait;
Printer.BeginDoc;
Printer.Canvas.TextOut(0,0,'Hello world...');
NewOrientation(Printer.Handle,1); // Printer.Orientation :=
poLandscape;
Printer.NewPage;
Printer.Canvas.TextOut(0,25,'Hello world...');
end;
Good luck.
Cheers
Martin Cremer
----- Original Message -----
From: EJP
Newsgroups: borland.public.delphi.vcl.components.using
Sent: Tuesday, December 05, 2000 7:43 PM
Subject: Any way to change Printer.Orientation mid job?
I'm looking for a way to change the orientation of a single page in a
multipage
print job without having to print it as a separate document.
Printer.Orientation
can't be changed while printing.
TIA,
Jay