uses Dialogs, SysUtils, Forms, hyieutils;

const
	magik:string='IMAGEENDEMOBYENCOMPSENCOMPSENCO';
	KNOWNKEY:array [0..15] of char='a A b B c C d D';
	KNOWNIV:array [0..15] of byte=(1,2,3,9,10,22,40,90,1,2,31,44,50,6,0,8);
   // 'ImageEn demo version - copyright by Hyrix Technologies'
	msg:array [0..53] of byte=(175,186,117,136,45,220,130,69,12,252,53,61,206,66,61,117,69,62,168,17,169,9,21,229,233,251,70,197,28,245,70,187,237,222,1,159,81,4,249,41,63,89,91,150,173,125,142,225,104,160,222,35,33,127);


// salva in 'c:\alfa.txt' il messaggio "txt" crittato con chiave KNOWNKEY e KNOWIV
procedure savemsg(txt:pchar);
var
	fs:textfile;
	keydata:TRC6Data;
   q:integer;
   ptr:pbyte;
begin
	getmem(ptr,length(txt)+1);
	RC6init(keydata,@KNOWNKEY,16,@KNOWNIV);
   RC6EncryptCFB(keydata,txt,ptr,length(txt));
   assign(fs,'c:\alfa.txt');
   rewrite(fs);
   for q:=0 to length(txt)-1 do
	   write(fs,inttostr(pbytearray(ptr)^[q])+',');
   closefile(fs);
   freemem(ptr);
end;

function _ctrl:boolean;
var
	q,chk:integer;
   keydata:TRC6data;
   xmsg:array [0..54] of char;
begin
	//savemsg('ImageEn demo version - copyright by Hyrix Technologies');
	result:=true;
   chk:=0;
   for q:=1 to 31 do
		inc(chk,ord(magik[q]));
   if chk<>2236 then begin
		rc6init(keydata,@KNOWNKEY,16,@KNOWNIV);
      RC6DecryptCFB(keydata,@(msg[0]),@(xmsg[0]),54);
      xmsg[54]:=#0;
   	MessageDlg(string(xmsg),mtWarning,[mbOK],0);
   end;
end;

initialization
	_ctrl;


