Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Terminal > NANO > BASH > XOR Files

Sep 7, 2012 12:58AM PDT

I would like to XOR each byte of a file with the corresponding byte of another file, creating an output file of the XOR'ed bytes using BASH.

Currently, I can use the terminal in OS X, changing directories, listing their contents, and using nano. I believe I will need to write a collection of BASH commands in nano and save them as an executable file.

Any hints would be greatly appreciated.

Jim Adrian
jim@futurebeacon.com

Discussion is locked

- Collapse -
Answer
Didn't find a native command for that.
Sep 7, 2012 2:37AM PDT

I can't guess why you would do such a thing but look up the old ROT13 and see if that command will do.
Bob

- Collapse -
Terminal > NANO > BASH > XOR Files
Sep 7, 2012 3:14AM PDT

by R. Proffitt Moderator - 9/7/12 9:37 AM

In Reply to: Terminal > NANO > BASH > XOR Files by jamesadrian

I can't guess why you would do such a thing but look up the old ROT13 and see if that command will do.
Bob
-----------------

R. Proffitt,

Thank you for your reply.

I don't know what ROT13 is or where to look for it.

I have read that a ^ b is the command used to XOR a and b. I would guess that the result would become the new A, but I'm not sure. The byte a comes from a text file A, and b is a byte from a file of pseudo-random numbers called B. A can be assumed to have the save file size as B.

I will Google ROT13. All hints are appreciated.

Thank you for your help.

Jim Adrian
jim@futurebeacon.com

- Collapse -
To speed things along.
Sep 7, 2012 3:22AM PDT

Try the google before the new post.

http://en.wikipedia.org/wiki/ROT13 shows it along with the "tr" command. Maybe your XOR could be done with a tr command but that's for you to decode since it's your files at risk. I will point out the usual solutions but because you must have a firm grasp of what you are doing, the final code in the script is for you to write.

Sorry, but that's the way I code.
Bob