Board index » delphi » Password for .res files

Password for .res files


2004-08-08 10:40:52 AM
delphi225
Can we put password for our .res (resource) files?
I really appreciate any help.
Thanks in advance
Steve
 
 

Re:Password for .res files

Steve writes:
Quote
Can we put password for our .res (resource) files?
No. Why would you want to?
--
Yorai Aminov (TeamB)
(TeamB cannot answer questions received via email.)
Shorter Path - www.shorterpath.com
Yorai's Page - www.yoraispage.com
 

Re:Password for .res files

Hi,
i want to put my pics in a resource file and read it in runtime. Is it
possible to read the pics from a res file in runtime?
Thanks in advance,
Steve
"Yorai Aminov (TeamB)" <XXXX@XXXXX.COM>writes
Quote
Steve writes:

>Can we put password for our .res (resource) files?

No. Why would you want to?

--
Yorai Aminov (TeamB)
(TeamB cannot answer questions received via email.)
Shorter Path - www.shorterpath.com
Yorai's Page - www.yoraispage.com
 

Re:Password for .res files

Quote
i want to put my pics in a resource file and read it in runtime. Is
it possible to read the pics from a res file in runtime?
Use the image editor installed with Delphi to create the resource file,
add a $R compiler directive for including it in your project, create a
TBitmap object and call it is LoadFromResourceName method to load the
image.
 

Re:Password for .res files

What is the point of password-protecting a file that contains some graphics
(assuming you want the graphics to appear on the screen at some time), when
any user can make a screenshot and destile the graphics from the screenshot?
"Steve" <XXXX@XXXXX.COM>píše v diskusním příspěvku
Quote
Can we put password for our .res (resource) files?
I really appreciate any help.

Thanks in advance
Steve


 

Re:Password for .res files

Quote
What is the point of password-protecting a file that contains some
graphics
(assuming you want the graphics to appear on the screen at some time),
when
any user can make a screenshot and destile the graphics from the
screenshot?
The graphics might not be displayed directly. Think of textures in a 3D
game, it is very hard to capture them from the screen (just to say something
stupid :-).
Jens
 

Re:Password for .res files

Quote
Can we put password for our .res (resource) files?
I really appreciate any help.
You can store any data in .res files, even password protected or encrypted
data, but there is no direct way, you have to do the protection by yourself.
If you are talking about bitmaps, you could apply some bijective filter on
them before adding them to the resource, and apply some undo filter when you
read them. The easiest way probably is to xor every RGB value with some
secret values (your "password"), and xor the RGB values again to restore the
original bitmap. Of course you can do the same with other data as well (but
it might be more difficult).
Jens
 

Re:Password for .res files

My resource contains audio and video as well, not just pictures.
"Pavel Vymazal" <XXXX@XXXXX.COM>writes
Quote
What is the point of password-protecting a file that contains some
graphics
(assuming you want the graphics to appear on the screen at some time),
when
any user can make a screenshot and destile the graphics from the
screenshot?

"Steve" <XXXX@XXXXX.COM>píše v diskusním příspěvku
news:XXXX@XXXXX.COM...
>Can we put password for our .res (resource) files?
>I really appreciate any help.
>
>Thanks in advance
>Steve
>
>


 

Re:Password for .res files

Would you please give me more details or a link with example.
Thanks
"Jens Gruschel" <XXXX@XXXXX.COM>writes
Quote
>Can we put password for our .res (resource) files?
>I really appreciate any help.

You can store any data in .res files, even password protected or encrypted
data, but there is no direct way, you have to do the protection by
yourself.
If you are talking about bitmaps, you could apply some bijective filter on
them before adding them to the resource, and apply some undo filter when
you
read them. The easiest way probably is to xor every RGB value with some
secret values (your "password"), and xor the RGB values again to restore
the
original bitmap. Of course you can do the same with other data as well
(but
it might be more difficult).

Jens


 

Re:Password for .res files

Steve writes:
Quote
i want to put my pics in a resource file and read it in runtime. Is
it possible to read the pics from a res file in runtime?
You'll have to link in the resources, and you can not encrypt them. If
you want to keep encryted graphics in an external file, create your own
custom file fomat.
--
Yorai Aminov (TeamB)
(TeamB cannot answer questions received via email.)
Shorter Path - www.shorterpath.com
Yorai's Page - www.yoraispage.com
 

Re:Password for .res files

Quote
Would you please give me more details or a link with example.
Thanks
procedure ProtectBitmap(const Bitmap: TBitmap; const Password: String);
var
X, Y, B: Integer;
P: ^Byte;
I, L: Integer;
BytesPerPixel: Integer;
begin
if Bitmap.PixelFormat = pf8bit then BytesPerPixel := 1
else if Bitmap.PixelFormat = pf15bit then BytesPerPixel := 2
else if Bitmap.PixelFormat = pf16bit then BytesPerPixel := 2
else if Bitmap.PixelFormat = pf24bit then BytesPerPixel := 3
else if Bitmap.PixelFormat = pf32bit then BytesPerPixel := 4
else raise Exception.Create('Pixel format not supported');
if Length(Password) < 1 then raise Exception.Create('Password empty');
I := 1;
L := Length(Password);
for Y := 0 to Bitmap.Height - 1 do begin
P := Bitmap.ScanLine[Y];
for X := 0 to Bitmap.Width - 1 do begin
for B := 1 to BytesPerPixel do begin
P^ := P^ xor Byte(Password[I]);
Inc(P);
Inc(I);
if I>L then I := 1;
end;
end;
end;
end;
Note that I have not tested this routine, that is not optimized for speed, and
that it only handles a limited number of pixel formats. You can use it to
protect (before adding it to a resource) and to unprotect a bitmap (using
the same password).
The longer the password the better. But the protection is limited, you can
only protect bitmaps this way from normal users, not from people who have
knowledge in protection mechanisms and graphics manipulation. If someone
extracts the bitmap from the resource (with a grabber) he still can read the
bitmap, but he will see (depending on your password) only rubbish. But
better solutions are more difficult to implement of course.
Jens
 

Re:Password for .res files

Thanks for your kind help Jens.
Steve
"Jens Gruschel" <XXXX@XXXXX.COM>writes
Quote
>Would you please give me more details or a link with example.
>Thanks

procedure ProtectBitmap(const Bitmap: TBitmap; const Password: String);
var
X, Y, B: Integer;
P: ^Byte;
I, L: Integer;
BytesPerPixel: Integer;
begin
if Bitmap.PixelFormat = pf8bit then BytesPerPixel := 1
else if Bitmap.PixelFormat = pf15bit then BytesPerPixel := 2
else if Bitmap.PixelFormat = pf16bit then BytesPerPixel := 2
else if Bitmap.PixelFormat = pf24bit then BytesPerPixel := 3
else if Bitmap.PixelFormat = pf32bit then BytesPerPixel := 4
else raise Exception.Create('Pixel format not supported');
if Length(Password) < 1 then raise Exception.Create('Password empty');
I := 1;
L := Length(Password);
for Y := 0 to Bitmap.Height - 1 do begin
P := Bitmap.ScanLine[Y];
for X := 0 to Bitmap.Width - 1 do begin
for B := 1 to BytesPerPixel do begin
P^ := P^ xor Byte(Password[I]);
Inc(P);
Inc(I);
if I>L then I := 1;
end;
end;
end;
end;

Note that I have not tested this routine, that is not optimized for speed,
and
that it only handles a limited number of pixel formats. You can use it to
protect (before adding it to a resource) and to unprotect a bitmap (using
the same password).
The longer the password the better. But the protection is limited, you can
only protect bitmaps this way from normal users, not from people who have
knowledge in protection mechanisms and graphics manipulation. If someone
extracts the bitmap from the resource (with a grabber) he still can read
the
bitmap, but he will see (depending on your password) only rubbish. But
better solutions are more difficult to implement of course.

Jens