3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Non bitwise XOR curiosity for encryption

Non bitwise XOR curiosity for encryption

I was searching the Internet for a string based XOR function and I was unable to come up with anything. There were people looking but a lot of  "experts" claimed that there was no such thing. I decided to take it upon myself to see if they were correct or not.
 
Remove these adsRemove these ads by Signing Up
 

Step 1What the heck is XOR

What the heck is XOR

First for a little background. XOR (exclusive OR) is what's called a bit-wise operation. It breaks down into a truth table as follows:

A(in) B(in) C(out)
 0        0        0
 1        0        1
 0        1        1
 1        1        0

This may seem a little less than impressive but it has larger applications especially in the field of encryption. If you put two bytes together via bit-wise XOR the result and one of the original inputs will return the second input.

Example:
             If A=010101
         and B=101010 then an XOR operation would result
                 C=111111.

             If C=111111
         and B=101010 then an XOR operation would result
                      010101 which is A

the same is true of the XOR of C and A = B.

So there you have an overview of bit-wise XOR operation and the application that I am interested in.

.
« Previous StepDownload PDFView All StepsNext Step »
2 comments
Jan 26, 2011. 3:12 AMSteamythepunk says:
Um yeah, so were you planning on using this in code or something?

Because bitwise logic has been around for that for ages.

A xor B could be written as

R = (~A & B) ¦ (A & ~B) where A and B are any given integers. You'd simply have to go through the string a character (or byte) at a time, running this function on it.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
17
Followers
6
Author:jds1969