Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: reading LSB of binarydata

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default reading LSB of binarydata

    i am able to change the content of text file to binary but now i have to select all the LSB of that binary data for further work how can i do that


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: reading LSB of binarydata

    By LSB I assume you mean the Least Significant Byte of an int value.
    To get that byte, AND the int value with 0xFF.

    i am able to change the content of text file to binary
    I'm not sure what that means. A file is made up of bytes. A byte is made of 8 binary bits. There is not conversion needed when reading the bytes of a file. Can you explain and give an example.
    For example if the file contained these two bytes (in hex) 9591
    or in binary(1001 0101 1001 0001)
    what would the "changed" bytes look like?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: reading LSB of binarydata

    i mean to say i used byte[] b=filename.getBytes() to covert a text file into bytes now i need to change the LSB of that data

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: reading LSB of binarydata

    Please define what LSB means and give an example.

    byte[] b=filename.getBytes() to covert a text file into bytes
    Is filename a String? What does it contain? How is that related to the contents of a text file?
    Are the lineend characters from the file included in the bytes that are obtained?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: reading LSB of binarydata

    i need to hide text into image file so for that purpose i have read a text file and converted into binary now how do i select LSB from that data and embedd into another LSB of image
    Define what you mean by LSB of data.

    Can you give an example?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: reading LSB of binarydata

    LSB means least significant Bit and i am doing a project on staganographyso for that purpose ineed to hide LSB of text data into the LSB of image file.SO i need to read LSB which i dont no so i need your help.plz

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: reading LSB of binarydata

    hide LSB of text data
    What are you going to do with the other 7 bits? I assume the LSB is of a byte.

    If you read a file, byte by byte, and only save the LSB of each byte, then you would never be able to restore the full 8 bits of the byte having only saved the LSB.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: reading LSB of binarydata

    ok thanx for that sugestion then now what i have to do to hide whole text data into an image file just give me some hints so that i can work .

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: reading LSB of binarydata

    To hide the whole text take the bits of each byte of the text and save them in the LSB of each byte in the image. First bit of first byte of text in LSB of first byte of image, second bit in second byte, third bit in third byte etc
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: reading LSB of binarydata

    thanx
    to take each bits we have to read the bytes of the text files right but then howto save them in lsb of image?

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: reading LSB of binarydata

    Here's a suggestion: Work with ByteArray streams for easier debugging.
    Write a method that takes two input streams and one output stream. Read the bits from one input stream, add its bits to the LSB of the other stream and write to the output stream.
    Then another method that takes an input stream (with the hidden text) and an output stream that gets the LSBs of the input stream, makes bytes and writes the bytes to the output stream.

    howto save them in lsb of image?
    Use the OR operator to set a bit in an int: 0b100 OR 0b001 gives 0b101
    Use the AND operator to clear a bit:
    0b011(input) AND 0b110 (the filter) gives 0b010 clearing the LSB

    NOTE: I'm using 0b to denote binary
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. character reading
    By deependeroracle in forum Java Theory & Questions
    Replies: 5
    Last Post: September 19th, 2014, 12:06 PM
  2. [SOLVED] Help with reading from file
    By Dr.Code in forum File I/O & Other I/O Streams
    Replies: 6
    Last Post: July 2nd, 2012, 07:44 AM
  3. Reading in numbers
    By Harlow777 in forum AWT / Java Swing
    Replies: 1
    Last Post: March 30th, 2012, 09:54 PM
  4. Help with reading from file
    By drazenmd in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 15th, 2010, 03:43 AM
  5. Reading file
    By nasi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 3rd, 2010, 03:14 AM

Tags for this Thread