how to XOR a document

This is a discussion on how to XOR a document within the C Programming forums, part of the General Programming Boards category; i want to XOR a byte with another byte in a document and then doing XOR of the result obtained ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    Unhappy how to XOR a document

    i want to XOR a byte with another byte in a document and then doing XOR of the result obtained with next byte of a document,similarly XORing the whole document.please explain with an example

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Where are you stuck?
    Reading bytes? Using XOR?

    Please reply with the code you have so far.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    xorValue = initialValue;
    while not done
        toXor = nextValue( fromSomeplace );          
        toXor ^= xorValue;
        doSomethingWith( toXor );
        xorValue = toXor;
    It's pretty basic. That should do what you need.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    _ Munkey01's Avatar
    Join Date
    Dec 2002
    Posts
    280
    What acually does XOR do?

  5. #5
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    XOR means exclusive OR, where if both of the bits being tested are different, the result is 1, 0 if they're the same :-)
    *Cela*

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Munkey01
    What acually does XOR do?
    Here is a good text on the subject.

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    When we use the word OR in our daily lives, we usually mean exclusive or (XOR). If you say "I'm gonna rent a movie or go to the cinema" you mean "rent a movie" OR "go to the cinema", not both, which is exactly what XOR is. One or the other, not both.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to properly document a program
    By firyace in forum C Programming
    Replies: 6
    Last Post: 05-24-2007, 10:31 AM
  2. Document Class and Dialog Windows :: MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 12-01-2002, 12:27 AM
  3. MultiDocument And MultView (and per document) :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-09-2002, 10:00 AM
  4. Scanning a line in a document
    By bc120 in forum C Programming
    Replies: 5
    Last Post: 01-02-2002, 02:06 PM
  5. Getting document point co-ordinates
    By swordfish in forum C++ Programming
    Replies: 2
    Last Post: 09-05-2001, 01:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21