473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

steganography in java

184 100+
Hi All,
I'm trying to encrypt the message in the gif image.
is there any algorithm for that to do?
I'm able to get create new image ,and even i retrieved the byte[] of the image.
I want to know how to add the "message" in that byte[].
As we know that messages needed to added at LSB inorder to retaining the
original image.I dont know how to add at LSB.

When i was surfing thro google i came across the contents at
http://www.dreamincode.net/forums/showtopic27950.htm
In that i couldnt get "Bit_Conversion" and "Encode_text" part..
can anyone pl help me ASAP..
Thanks in Advance

-Thanks & Regards,
Hamsa
Mar 11 '08 #1
12 6062
sukatoa
539 512MB
Hi All,
I'm trying to encrypt the message in the gif image.
is there any algorithm for that to do?
I'm able to get create new image ,and even i retrieved the byte[] of the image.
I want to know how to add the "message" in that byte[].
As we know that messages needed to added at LSB inorder to retaining the
original image.I dont know how to add at LSB.

When i was surfing thro google i came across the contents at
http://www.dreamincode.net/forums/showtopic27950.htm
In that i couldnt get "Bit_Conversion" and "Encode_text" part..
can anyone pl help me ASAP..
Thanks in Advance

-Thanks & Regards,
Hamsa
Maybe this
could help you....

Sukatoa...
Mar 11 '08 #2
gaya3
184 100+
Maybe this
could help you....

Sukatoa...
Thank u Sukatoa... As i'm very much new to this.. I need some basement for that LSB Conversion.. Could u pl help me out?

-Thanks & regards,
Hamsa
Mar 11 '08 #3
JosAH
11,448 Expert 8TB
Thank u Sukatoa... As i'm very much new to this.. I need some basement for that LSB Conversion.. Could u pl help me out?

-Thanks & regards,
Hamsa
For those bit operations: let xxxxxxxx be the eight bits in a byte. Let b be a single
bit, either 1 or 0. The following code snippet changes the lowest bit of xxxxxxxx
to b; Here goes:

Expand|Select|Wrap|Line Numbers
  1. byte xxxxxxxx= ...; // some byte value
  2. byte b= ...; // either 0 or 1
  3. byte xxxxxxxx= (byte)((xxxxxxxx&0xfe)|b);
  4.  
The value 0xfe in binary is 11111110; if you 'and' another byte value with this you
effectively set the lowest bit to zero. 'or'ing it with 'b' afterwards sets the lowest
bit to 'b'.

kind regards,

Jos
Mar 11 '08 #4
sukatoa
539 512MB
Thank u Sukatoa... As i'm very much new to this.. I need some basement for that LSB Conversion.. Could u pl help me out?

-Thanks & regards,
Hamsa
Truth table about AND

a and b = fout

0 0 0
0 1 0
1 0 0
1 1 1


Truth table about OR

a or b = fout

0 0 0
0 1 1
1 0 1
1 1 1

in a register, there are 2 bytes...
since you are focusing in lower significant bit....

at lower byte or higher, there are 8 binary numbers either 0 or 1

first 4 bits (binary digits) are the HSB and the second 4 bit is the LSB

ex. 0000 0000

Applying the AND and OR conversion

AND
0000 0000
1111 1111
---------------------
0000 0000

OR
0000 0000
1111 1111
---------------------
1111 1111

I have not yet experience that kind of implementation in java... I only use it in Assembly...

I hope you could get some idea here...

Apply jo's reply....
Mar 11 '08 #5
gaya3
184 100+
For those bit operations: let xxxxxxxx be the eight bits in a byte. Let b be a single
bit, either 1 or 0. The following code snippet changes the lowest bit of xxxxxxxx
to b; Here goes:

Expand|Select|Wrap|Line Numbers
  1. byte xxxxxxxx= ...; // some byte value
  2. byte b= ...; // either 0 or 1
  3. byte xxxxxxxx= (byte)((xxxxxxxx&0xfe)|b);
  4.  
The value 0xfe in binary is 11111110; if you 'and' another byte value with this you
effectively set the lowest bit to zero. 'or'ing it with 'b' afterwards sets the lowest
bit to 'b'.

kind regards,

Jos

Thank u Jos.. Thanks a lot..
Your explanation left me no point for further clarification in LSB conversion..
I need one small clarifiaction for "bit conversion" in this link..
http://www.dreamincode.net/forums/showtopic27950.htm
what they are trying to do there? I couldnt get that..pl help me out..

-Thanks & Regards,
Hamsa
Mar 12 '08 #6
JosAH
11,448 Expert 8TB
You mean this method? (ripped from that link):

Expand|Select|Wrap|Line Numbers
  1. private byte[] bit_conversion(int i)
  2. {        
  3.     byte byte3 = (byte)((i & 0xFF000000) >>> 24); 
  4.     byte byte2 = (byte)((i & 0x00FF0000) >>> 16); 
  5.     byte byte1 = (byte)((i & 0x0000FF00) >>> 8 ); 
  6.     byte byte0 = (byte)((i & 0x000000FF)       );
  7.     return(new byte[]{byte3,byte2,byte1,byte0});
  8. }
  9.  
That int i value represents a color 'ARGB' which is a four byte value in one int:
the alpha factor and the red, green and blue component values. The method
just pulls the four bytes out of that in and returns a four element byte array.

It gets those bytes (eight bits) by masking all the irrelevant bits away and shifting
the values to the lowest possible position.

kind regards,

Jos
Mar 12 '08 #7
gaya3
184 100+
You mean this method? (ripped from that link):

Expand|Select|Wrap|Line Numbers
  1. private byte[] bit_conversion(int i)
  2. {        
  3.     byte byte3 = (byte)((i & 0xFF000000) >>> 24); 
  4.     byte byte2 = (byte)((i & 0x00FF0000) >>> 16); 
  5.     byte byte1 = (byte)((i & 0x0000FF00) >>> 8 ); 
  6.     byte byte0 = (byte)((i & 0x000000FF)       );
  7.     return(new byte[]{byte3,byte2,byte1,byte0});
  8. }
  9.  
That int i value represents a color 'ARGB' which is a four byte value in one int:
the alpha factor and the red, green and blue component values. The method
just pulls the four bytes out of that in and returns a four element byte array.

It gets those bytes (eight bits) by masking all the irrelevant bits away and shifting
the values to the lowest possible position.

kind regards,

Jos
Jos i have got new concept from you.. Does "i" is not something like message length? which means the message v need to encrypt.then where does 'ARGB' comes to picture?sorry for inconvenience .if you dont mind, can u please explain me with example?

-Thanks & Regards,
Hamsa
Mar 12 '08 #8
Hi ,

i am also doing Steganography project to hide msg in GIF.
Could I know, Is it need to decompress the gif and chnage the bit then compress it to become the Stegoed Image?

I am facing the problem on the loading of GIF file into the int[].
anyone know how was the GIF structure work ?


Regards
Kit
Mar 13 '08 #9
BigDaddyLH
1,216 Expert 1GB
Hi ,

i am also doing Steganography project to hide msg in GIF.
Could I know, Is it need to decompress the gif and chnage the bit then compress it to become the Stegoed Image?

I am facing the problem on the loading of GIF file into the int[].
anyone know how was the GIF structure work ?


Regards
Kit
It's simpler to ignore the image's file format. Read in the image:

Expand|Select|Wrap|Line Numbers
  1. BufferedImage image = ImageIO.read(inFile);
Tweak pixel bits then write it out:

Expand|Select|Wrap|Line Numbers
  1. ImageIO.write(image, "gif", outFile);
Here is an example I wrote awhile back, under a different username:

http://forum.java.sun.com/thread.jsp...074389&start=2

The message embedded is the program for embedding the message!
Mar 13 '08 #10
gaya3
184 100+
It's simpler to ignore the image's file format. Read in the image:

Expand|Select|Wrap|Line Numbers
  1. BufferedImage image = ImageIO.read(inFile);
Tweak pixel bits then write it out:

Expand|Select|Wrap|Line Numbers
  1. ImageIO.write(image, "gif", outFile);
Here is an example I wrote awhile back, under a different username:

http://forum.java.sun.com/thread.jsp...074389&start=2

The message embedded is the program for embedding the message!

Hi,
Thank u.. Example u have shown is quite good..
i like to know what for this following block needed in that example?

static byte[] convert(int x) {
int b3 = (x & 0xff000000) >>> 24;
int b2 = (x & 0xff0000) >>> 16;
int b1 = (x & 0xff00) >>> 8;
int b0 = x & 0xff;
return new byte[]{(byte)b3, (byte)b2, (byte)b1, (byte)b0};
}
what they are trying to do in the above code?

-Thanks & Regards,
Hamsa
Mar 14 '08 #11
JosAH
11,448 Expert 8TB
Hi,
Thank u.. Example u have shown is quite good..
i like to know what for this following block needed in that example?

static byte[] convert(int x) {
int b3 = (x & 0xff000000) >>> 24;
int b2 = (x & 0xff0000) >>> 16;
int b1 = (x & 0xff00) >>> 8;
int b0 = x & 0xff;
return new byte[]{(byte)b3, (byte)b2, (byte)b1, (byte)b0};
}
what they are trying to do in the above code?

-Thanks & Regards,
Hamsa
That's the same thing you were asking about to me. Suppose a four byte number:
aarrggbb, where the a's, r's, g's and b's are hexadecimal digits.

aarrgbb &0xff000000 == aa000000
aa000000 >>> 24 == aa

aarrggbb &0xff0000 == rr0000
rr0000 >>> 16 == rr

etc. etc.

That little method takes apart the four bytes in an int and stores the bytes in a
byte array.

kind regards,

Jos
Mar 14 '08 #12
BigDaddyLH
1,216 Expert 1GB
That's the same thing you were asking about to me. Suppose a four byte number:
aarrggbb, where the a's, r's, g's and b's are hexadecimal digits.

aarrgbb &0xff000000 == aa000000
aa000000 >>> 24 == aa

aarrggbb &0xff0000 == rr0000
rr0000 >>> 16 == rr

etc. etc.

That little method takes apart the four bytes in an int and stores the bytes in a
byte array.

kind regards,

Jos
Indeed. You should be able to guess the intent of the method from its signature alone!
Mar 14 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Michael | last post by:
Hello I am trying to write a Java-Program which converts a XML-file in a HTML. It should take the Transformation-file from the XML-file itself. Below find a possible XML-file: <?xml...
0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
1
by: ThoughtProvoker | last post by:
Ive recently migrated for Visual Basic 6.0 to VB.NET and ive exprerience of many skills of it and recently i am trying to perform Least Significant Bit Steganography in it and im unable to do so...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: Markus Wollny | last post by:
Hello! When I try to run ./configure --with-java, it complains that ant doesn't work. However ant is installed, as is the latest Java SDK 1.4.2 from sun, PATH and JAVA_HOME are set correctly; ...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
by: radix2 | last post by:
hello, anybody can help me to make application encryption(using AES 256 bit)+steganography(using LSB insertion technique)...thanks before..i really need help....
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.