Posts

Showing posts from November, 2011

C Programs|Examples of C program| C++ program on Encryption| Program of Encryption in C++ Linux OS| Dos OS

C programs | Simple examples of C programs, C programs examples, C programming for beginers C C++ programs using Linux DOS. C and C++ uses ^ for bit-level exclusive-OR. To encrypt a single character you can use char x=x^key; if you have a key of one byte. To encrypt a string of characters with a longer key, you can use something like to the following code in C++: #include <iostream.h> int main() { char string[11]="A Program "; char key[11]="ABCDEFGHIJ"; for(int x=0; x<10; x++) { string[x]=string[x]^key[x]; cout<<string[x]; } return 0; } The program encrypts each character in the string using the ^ bit operator to exclusive-OR the string value with the key value for each character. Truth Table:: exclusive-OR,  will return true if one, and only one, of the two operators is true. The truth table is as follows: A B A XOR B T T F T F T F T T F F F