steganography in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaya3
    New Member
    • Aug 2007
    • 184

    steganography in java

    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

    In that i couldnt get "Bit_Conversion " and "Encode_tex t" part..
    can anyone pl help me ASAP..
    Thanks in Advance

    -Thanks & Regards,
    Hamsa
    Last edited by gaya3; Mar 11 '08, 10:46 AM. Reason: change in Topic
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by gaya3
    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

    In that i couldnt get "Bit_Conversion " and "Encode_tex t" part..
    can anyone pl help me ASAP..
    Thanks in Advance

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

    Sukatoa...

    Comment

    • gaya3
      New Member
      • Aug 2007
      • 184

      #3
      Originally posted by sukatoa
      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

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by gaya3
        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:

        [code=java]
        byte xxxxxxxx= ...; // some byte value
        byte b= ...; // either 0 or 1
        byte xxxxxxxx= (byte)((xxxxxxx x&0xfe)|b);
        [/code]

        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

        Comment

        • sukatoa
          Contributor
          • Nov 2007
          • 539

          #5
          Originally posted by gaya3
          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....

          Comment

          • gaya3
            New Member
            • Aug 2007
            • 184

            #6
            Originally posted by JosAH
            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:

            [code=java]
            byte xxxxxxxx= ...; // some byte value
            byte b= ...; // either 0 or 1
            byte xxxxxxxx= (byte)((xxxxxxx x&0xfe)|b);
            [/code]

            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

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              You mean this method? (ripped from that link):

              [code=java]
              private byte[] bit_conversion( int i)
              {
              byte byte3 = (byte)((i & 0xFF000000) >>> 24);
              byte byte2 = (byte)((i & 0x00FF0000) >>> 16);
              byte byte1 = (byte)((i & 0x0000FF00) >>> 8 );
              byte byte0 = (byte)((i & 0x000000FF) );
              return(new byte[]{byte3,byte2,by te1,byte0});
              }
              [/code]

              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

              Comment

              • gaya3
                New Member
                • Aug 2007
                • 184

                #8
                Originally posted by JosAH
                You mean this method? (ripped from that link):

                [code=java]
                private byte[] bit_conversion( int i)
                {
                byte byte3 = (byte)((i & 0xFF000000) >>> 24);
                byte byte2 = (byte)((i & 0x00FF0000) >>> 16);
                byte byte1 = (byte)((i & 0x0000FF00) >>> 8 );
                byte byte0 = (byte)((i & 0x000000FF) );
                return(new byte[]{byte3,byte2,by te1,byte0});
                }
                [/code]

                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

                Comment

                • waikit0513
                  New Member
                  • Apr 2007
                  • 1

                  #9
                  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

                  Comment

                  • BigDaddyLH
                    Recognized Expert Top Contributor
                    • Dec 2007
                    • 1216

                    #10
                    Originally posted by waikit0513
                    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:

                    [CODE=Java]BufferedImage image = ImageIO.read(in File);[/CODE]

                    Tweak pixel bits then write it out:

                    [CODE=Java]ImageIO.write(i mage, "gif", outFile);[/CODE]

                    Here is an example I wrote awhile back, under a different username:



                    The message embedded is the program for embedding the message!

                    Comment

                    • gaya3
                      New Member
                      • Aug 2007
                      • 184

                      #11
                      Originally posted by BigDaddyLH
                      It's simpler to ignore the image's file format. Read in the image:

                      [CODE=Java]BufferedImage image = ImageIO.read(in File);[/CODE]

                      Tweak pixel bits then write it out:

                      [CODE=Java]ImageIO.write(i mage, "gif", outFile);[/CODE]

                      Here is an example I wrote awhile back, under a different username:



                      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

                      Comment

                      • JosAH
                        Recognized Expert MVP
                        • Mar 2007
                        • 11453

                        #12
                        Originally posted by gaya3
                        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

                        Comment

                        • BigDaddyLH
                          Recognized Expert Top Contributor
                          • Dec 2007
                          • 1216

                          #13
                          Originally posted by JosAH
                          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!

                          Comment

                          Working...