Welcome Guest [Log In] [Register]
Welcome to Crypto. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Picture Encrypter
Topic Started: Aug 28 2005, 09:43 AM (272 Views)
Revelation
Member Avatar
Administrator
[ *  *  *  *  * ]
You might know I am a Delphi programmer, and I made this app: Picture Encrypter. It is capable of hiding text in an image by altering the color a little. This change is not visible, so no one will notice. If you want to decrypt the image, load the encrypted image and press decrypt. Then you will have to load the image without the text. If someone else has made an application concerning security/cryptography, don't be afraid to post it! :)

Download it here.
RRRREJMEEEEEPVKLWENFNVJKEEEEEAOLKAFKLXCFZAASDJXZTTTTTTTLSIOWJXMOKLAFJNNKFNXN
RAGRBAQEMHIGDJVDSEOXVIYCELFHWLELJFIENXLRATALSJFSLCYTKLASJDKMHGOVOKAJDNMNUITN
RRRRLJVEEEEECLYVYHNVPFTAEEEEEMWLMEIRNGLARWJAKJDFLWNTIERJMIPQWOTZEOCXKNUBNXCN
RJIRPOWEANFUSNCZVDVZNMSFEKLOEPZLDKDJWSAAAAAAAOERHJCTNCKFRIMVKSOFOMKMANREWNBN
RZUDRGXEEEEENFQIDVLQNCKNEEEEEDGLLLLLLAWIOSNCDARLODMTOEJXMILDFJROTKJSDNLVCZNN
Offline Profile Quote Post Goto Top
 
PulsarSL
Super member
[ *  *  *  * ]
Revelation
Aug 28 2005, 09:43 AM
You might know I am a Delphi programmer, and I made this app: Picture Encrypter. It is capable of hiding text in an image by altering the color a little. This change is not visible, so no one will notice. If you want to decrypt the image, load the encrypted image and press decrypt. Then you will have to load the image without the text. If someone else has made an application concerning security/cryptography, don't be afraid to post it! :)

Download it here.

That's awesome. Believe it or not, I was just searching for a program like this earlier today.

If you don't mind sharing the source, can you please post it here or send it to my email (pulsarsl@gmail.com)? If you don't want to, I completley understand being a fellow programmer.

Thanks,
PulsarSL
Offline Profile Quote Post Goto Top
 
PulsarSL
Super member
[ *  *  *  * ]
I've made a rather simple (and truly pitiful) demonstration of a little (and probably insecure) algorithim I made.

You can download it at http://rapidshare.de/files/4592714/XOR_encryption.exe.html .

<PARANOID DISCLAIMER>
You can't hold me responsible for any damages it causes.
</PARANOID DISCLAIMER>

:D

--PulsarSL
Offline Profile Quote Post Goto Top
 
Revelation
Member Avatar
Administrator
[ *  *  *  *  * ]
It is insecure :)

Xor-ing isn't a great idea for encryptions if you don't do it multiple times and then hash it or something. Notice when you use the plain text as a key all the chars are spaces. :)

If you want to make an uncrackable encryption, use a one time pad. This means you add the byte value of every character with the one at the same x-position in the password (this should equal the size of the plain text) and then flip it back to a character.

btw, I will post the source soon. :)
RRRREJMEEEEEPVKLWENFNVJKEEEEEAOLKAFKLXCFZAASDJXZTTTTTTTLSIOWJXMOKLAFJNNKFNXN
RAGRBAQEMHIGDJVDSEOXVIYCELFHWLELJFIENXLRATALSJFSLCYTKLASJDKMHGOVOKAJDNMNUITN
RRRRLJVEEEEECLYVYHNVPFTAEEEEEMWLMEIRNGLARWJAKJDFLWNTIERJMIPQWOTZEOCXKNUBNXCN
RJIRPOWEANFUSNCZVDVZNMSFEKLOEPZLDKDJWSAAAAAAAOERHJCTNCKFRIMVKSOFOMKMANREWNBN
RZUDRGXEEEEENFQIDVLQNCKNEEEEEDGLLLLLLAWIOSNCDARLODMTOEJXMILDFJROTKJSDNLVCZNN
Offline Profile Quote Post Goto Top
 
Revelation
Member Avatar
Administrator
[ *  *  *  *  * ]
Here is the source-code, it is in pascal:

Code:
 

unit MainUnit;

interface

uses
 SysUtils, Graphics, Forms, Dialogs, ExtCtrls, StdCtrls, ExtDlgs,
 Classes, Controls;

type
 TMainForm = class(TForm)
   BtnDec: TButton;
   BtnEnc: TButton;
   Img1: TImage;
   Img2: TImage;
   TextMem: TMemo;
   LoadBtn: TButton;
   OpenPictureDialog: TOpenPictureDialog;
   SavePictureDialog: TSavePictureDialog;
   OpenPictureDialog2: TOpenPictureDialog;
   ScrollBox1: TScrollBox;
   ScrollBox2: TScrollBox;
   SaveBtn: TButton;
   Label1: TLabel;
   Label2: TLabel;
   procedure BtnDecClick(Sender: TObject);
   procedure BtnEncClick(Sender: TObject);
   procedure LoadBtnClick(Sender: TObject);
   procedure SaveBtnClick(Sender: TObject);
 end;

var
 MainForm: TMainForm;

implementation

uses Math;

{$R *.dfm}

procedure TMainForm.BtnDecClick(Sender: TObject);
var
 x, y: Integer;
 CharMask, AChar: Byte;
begin
 if OpenPictureDialog2.Execute then
 begin
   try
     Img2.Picture.LoadFromFile(OpenPictureDialog2.FileName);
   except
     raise Exception.Create('Error reading bitmap!');
     Exit;
   end;

   TextMem.Clear; // Remove the text
   CharMask := $80; // 128
   AChar := 0;

   with Img2.Picture.Bitmap do
   begin
     for y := 0 to Pred(Height) do
     begin
       for x := 0 to Pred(Width) do
       begin
         if (Img1.Picture.Bitmap.Canvas.Pixels[x, y] <>
           Canvas.Pixels[x, y]) then
           AChar := AChar or CharMask; // Build the character
         CharMask := CharMask shr 1;

         if CharMask = 0 then // If the mask is 0, the decryption of a char is
         begin // completed
           TextMem.Text := TextMem.Text + Char(AChar);
           CharMask := $80;
           AChar := 0;
         end;
       end;
     end;
   end;
 end
 else
   raise Exception.Create('Could not complete the requested action!');
end;

procedure TMainForm.BtnEncClick(Sender: TObject);
var
 x, y, a, b: Integer;
 CharMask: Byte;
begin
 Img2.Picture.Assign(Img1.Picture); // Assign the source to the target image
 x := 0;
 y := 0;

 with Img2.Picture.Bitmap do
 begin
   PixelFormat := pf32bit;

   for a := 1 to Length(TextMem.Text) do
   begin
     CharMask := $80; // 128

     for b := 1 to 8 do // 8 bytes for every letter to be encrypted
     begin
       // Check if the bit in the byte is not a 0
       if (Byte(TextMem.Text[a]) and CharMask <> 0) then
         Canvas.Pixels[x, y] := Canvas.Pixels[x, y] xor $1; // xor the value


       x := Succ(x) mod Width; // Move to the next pixel
       if (x = 0) then
         if y = Height then
         begin
           raise Exception.Create('The text doesn''t fit in the image!');
           Break;
         end
         else
           Inc(y);
       // Move on to the next bit
       CharMask := CharMask shr 1;
     end;

     if B <> 9 then
       Break; // if the exception was created, stop the second loop!
   end;
 end;

 SaveBtn.Enabled := True;
end;

procedure TMainForm.LoadBtnClick(Sender: TObject);
begin
 if OpenPictureDialog.Execute then
 try
   Img1.Picture.LoadFromFile(OpenPictureDialog.FileName);
 except
   raise Exception.Create('Error reading bitmap!');
   Img1.Picture.Bitmap := nil;
 end;

 BtnEnc.Enabled := Img1.Picture.Graphic <> nil;
 BtnDec.Enabled := BtnEnc.Enabled;
end;

procedure TMainForm.SaveBtnClick(Sender: TObject);
begin
 if SavePictureDialog.Execute then
 try
   Img2.Picture.SaveToFile(SavePictureDialog.FileName);
 except
   raise Exception.Create('Error saving bitmap!');
 end;
end;

end.


I hope you can read it :)
RRRREJMEEEEEPVKLWENFNVJKEEEEEAOLKAFKLXCFZAASDJXZTTTTTTTLSIOWJXMOKLAFJNNKFNXN
RAGRBAQEMHIGDJVDSEOXVIYCELFHWLELJFIENXLRATALSJFSLCYTKLASJDKMHGOVOKAJDNMNUITN
RRRRLJVEEEEECLYVYHNVPFTAEEEEEMWLMEIRNGLARWJAKJDFLWNTIERJMIPQWOTZEOCXKNUBNXCN
RJIRPOWEANFUSNCZVDVZNMSFEKLOEPZLDKDJWSAAAAAAAOERHJCTNCKFRIMVKSOFOMKMANREWNBN
RZUDRGXEEEEENFQIDVLQNCKNEEEEEDGLLLLLLAWIOSNCDARLODMTOEJXMILDFJROTKJSDNLVCZNN
Offline Profile Quote Post Goto Top
 
PulsarSL
Super member
[ *  *  *  * ]
Revelation
Sep 1 2005, 02:37 PM
It is insecure :)

Xor-ing isn't a great idea for encryptions if you don't do it multiple times and then hash it or something. Notice when you use the plain text as a key all the chars are spaces. :)

If you want to make an uncrackable encryption, use a one time pad. This means you add the byte value of every character with the one at the same x-position in the password (this should equal the size of the plain text) and then flip it back to a character.

btw, I will post the source soon. :)

How do you ensure the key and data are equal length? And how do you make sure that when you add them together, it isn't greater than the biggest byte value for a character? I'm not sure if that's clear...

BTW, thanks for the source, I'll take a look later today.
Offline Profile Quote Post Goto Top
 
Revelation
Member Avatar
Administrator
[ *  *  *  *  * ]
Code:
 
if Length(PlainText) = Length(Key) then

or something like that?

Don't make it a byte but a word or whatever that may be in VB. :)

RRRREJMEEEEEPVKLWENFNVJKEEEEEAOLKAFKLXCFZAASDJXZTTTTTTTLSIOWJXMOKLAFJNNKFNXN
RAGRBAQEMHIGDJVDSEOXVIYCELFHWLELJFIENXLRATALSJFSLCYTKLASJDKMHGOVOKAJDNMNUITN
RRRRLJVEEEEECLYVYHNVPFTAEEEEEMWLMEIRNGLARWJAKJDFLWNTIERJMIPQWOTZEOCXKNUBNXCN
RJIRPOWEANFUSNCZVDVZNMSFEKLOEPZLDKDJWSAAAAAAAOERHJCTNCKFRIMVKSOFOMKMANREWNBN
RZUDRGXEEEEENFQIDVLQNCKNEEEEEDGLLLLLLAWIOSNCDARLODMTOEJXMILDFJROTKJSDNLVCZNN
Offline Profile Quote Post Goto Top
 
PulsarSL
Super member
[ *  *  *  * ]
Revelation
Sep 1 2005, 06:55 PM
Code:
 
if Length(PlainText) = Length(Key) then

or something like that?

Don't make it a byte but a word or whatever that may be in VB. :)

No, I mean if you type a 3 page document and you want to encrypt it, you obviously don't want a 3 page key!

So if my text was "now is the time for all good men to come to the aid of their country" (68 characters if I counted correctly [probably didn't]), and my key is "mydogiscool" (11 characters), how would this work? Would you make the key

mydogiscoolmydogiscoolmydogiscoolmydogiscoolmydogiscoolmydogiscoolmy

Then it would be long enough? I mean, just keep repeating the key (basically)?

My second question was that when you add the two byte values, how do you ensure the resulting byte value actually corresponds to an ASCII character and isn't too large (i.e. going beyond 255's byte value?). It seems like if you added the byte values of 254 and 231, you'd not get a character when you tried to flip it back (there is no 485)... except of course, we're dealing with byte values and not just ascii numbers here. Forgive me if what I'm saying is completly stupid :D

Again, I'm not sure if this is clear, but I hope you'll understand.

--PulsarSL
Offline Profile Quote Post Goto Top
 
Revelation
Member Avatar
Administrator
[ *  *  *  *  * ]
Nope, it will start all over again from 0. This is not a problem though. If you substract it later, it will go from 0 to 255 . :)

I see what you mean. Note that this method is insecure and crackable, if you use a char for every plain text char it will be uncrackable.

Try something like this:

Code:
 

x := 1;
   for i := 1 to iText do
   begin
     Text := Memo1.Lines.Text[i];
     PW := sPw[x];
     if Sender = Button1 then
       Text := Chr(Ord(Text) + Ord(PW))
     else
       Text := Chr(Ord(Text) - Ord(PW));
     Memo2.Lines.Text := Memo2.Lines.Text + Text;
    Inc(i);
     if x = iPW then x := 1;
   end;


where x is an integer, Text a string, i an integer, iText the length of the Text, PW a char, sPw the string of the password, iPw the length of the password and memo2 a Memo (something like a richedit).

I made this app once, if the sender is button1 it will encrypt, else decrypt. It will add the ordinal value of the character (the byte) with the password one. If x reaches the length of the password, it will set it back to one. I hope you understand the code :)
RRRREJMEEEEEPVKLWENFNVJKEEEEEAOLKAFKLXCFZAASDJXZTTTTTTTLSIOWJXMOKLAFJNNKFNXN
RAGRBAQEMHIGDJVDSEOXVIYCELFHWLELJFIENXLRATALSJFSLCYTKLASJDKMHGOVOKAJDNMNUITN
RRRRLJVEEEEECLYVYHNVPFTAEEEEEMWLMEIRNGLARWJAKJDFLWNTIERJMIPQWOTZEOCXKNUBNXCN
RJIRPOWEANFUSNCZVDVZNMSFEKLOEPZLDKDJWSAAAAAAAOERHJCTNCKFRIMVKSOFOMKMANREWNBN
RZUDRGXEEEEENFQIDVLQNCKNEEEEEDGLLLLLLAWIOSNCDARLODMTOEJXMILDFJROTKJSDNLVCZNN
Offline Profile Quote Post Goto Top
 
PulsarSL
Super member
[ *  *  *  * ]
Revelation
Sep 2 2005, 12:47 PM
Nope, it will start all over again from 0. This is not a problem though. If you substract it later, it will go from 0 to 255 . :)

I see what you mean. Note that this method is insecure and crackable, if you use a char for every plain text char it will be uncrackable.

Try something like this:

Code:
 

x := 1;
   for i := 1 to iText do
   begin
     Text := Memo1.Lines.Text[i];
     PW := sPw[x];
     if Sender = Button1 then
       Text := Chr(Ord(Text) + Ord(PW))
     else
       Text := Chr(Ord(Text) - Ord(PW));
     Memo2.Lines.Text := Memo2.Lines.Text + Text;
    Inc(i);
     if x = iPW then x := 1;
   end;


where x is an integer, Text a string, i an integer, iText the length of the Text, PW a char, sPw the string of the password, iPw the length of the password and memo2 a Memo (something like a richedit).

I made this app once, if the sender is button1 it will encrypt, else decrypt. It will add the ordinal value of the character (the byte) with the password one. If x reaches the length of the password, it will set it back to one. I hope you understand the code :)

Yea, I get what you mean. Thanks for the explanation. I'll translate the source to VB or C++ later today and give it a shot.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · General · Next Topic »
Add Reply