Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    zhaoyun333's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Posts
    396
    Reputation
    11
    Thanks
    1,125
    Uhhhh you do know that characters are based on the 255 Ascii characters right? So when you have the string HELLO and your key is ZZZZZ:

    HELLO
    ^ ZZZZZ
    ↕ ▼ ▬ §

    What ^ actually does is it takes two binary numbers and takes the OR

    10011011
    ^ 01101101
    11110110

    It sets a bit in the resulting value if either bit has a bit set at that position

    So when you do this, you could get a number between 0 - 255 of which have different characters and such.
    There are five possible operations for any army. If you can fight, fight; if you cannot fight, defend; if you cannot defend, flee; if you cannot flee, surrender; if you cannot surrender, die." - Sima Yi

  2. #17
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by zhaoyun333 View Post
    Uhhhh you do know that characters are based on the 255 Ascii characters right? So when you have the string HELLO and your key is ZZZZZ:

    HELLO
    ^ ZZZZZ
    ↕ ▼ ▬ §

    What ^ actually does is it takes two binary numbers and takes the OR

    10011011
    ^ 01101101
    11110110

    It sets a bit in the resulting value if either bit has a bit set at that position

    So when you do this, you could get a number between 0 - 255 of which have different characters and such.
    Yeh I go that. The problem is finding the key. I'll use your example:

    10011011 - this was ur plaintext
    11110110 - this was ur ciphertext
    01101101 - XORed together they equal the key, but something is a little wrong with my encryption scheme, its creating letters that shouldn't have been there to start with.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  3. #18
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    I got it working why =D
    Code:
    #include <windows.h>
    #include <iostream>
    #include <fstream>
    using namespace std;
    void XOREncrypt(char *txt, char *key);
    
    int main()
    {
    	char txt[50];
    	char key[50];
    	while(1)
    	{
            cout<<"Enter the filename: ";
    		cin >> txt;
    		cout<<"Encryption Key: ";
    		cin >> key;
    		XOREncrypt(txt, key);
    	}
        return 1;
    }
    
    void XOREncrypt(char *txt, char *key)
    {
    	ifstream ttext;
    	ofstream tout;
    	int j=0;
    	ttext.open(txt);
    	tout.open("outp.txt");
    	char ch;
    	while(ttext.get(ch))
    	{
    		tout.put((int(ch)^int(key[j])));
    		j<int(strlen(key)-1)?j++:j=0;
    	}
    	tout.close();
    	ttext.close();
    }
    bug fixed, theres probly more bugs, but the decrypted text was the same
    Last edited by Hell_Demon; 12-12-2009 at 09:32 AM.
    Ah we-a blaze the fyah, make it bun dem!

  4. The Following User Says Thank You to Hell_Demon For This Useful Post:

    why06 (12-12-2009)

  5. #19
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by Hell_Demon View Post
    I got it working why =D


    bug fixed, theres probly more bugs, but the decrypted text was the same
    Thanks. I'll look into this and try to apply it to my own code, and find out what the problem might be.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  6. #20
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Fully working code:
    Code:
    #include <iostream>
    using namespace std;
    
    void XOREncrypt(char *pfile, char *pkey); // Forward declaration
    
    int main()
    {
    	char tmpfile[50];	// stores our filename
    	char key[50];		// stores our encryption key
    	while(1)			// Repeat for eternity :)
    	{
    		cout<<"Enter the file name: ";	// No need to explain
    		cin>>tmpfile;					// ^
    		cout<<"Encryption key: ";		// ^
    		cin>>key;						// ^
    		XOREncrypt(tmpfile, key);		// Call the XOREncrypt function
    	}
    	return 0;
    }
    
    void XOREncrypt(char *pfile, char *pkey)
    {
    	FILE *input, *output;				// File pointers <3
    	input=fopen(pfile, "rb");			// open the input file(mode: read+binary)
    	output=fopen("output.txt", "wb");	// open the output file(mode: write+bin)
    	if(input != NULL && output != NULL) // if they both opened succesfully
    	{
    		unsigned char buffer[64];	// unsigned char buffer to unfuck our previous errors
    									// Any size will do, it tries to read 64 bytes a time now
    		size_t i, j, rdln;	// size_t because thats what fread returns
    		i=0;j=0;rdln=0;		// init to 0
    		do // do
    		{
    			rdln = fread(buffer, sizeof(*buffer),sizeof(buffer),input); // read 64 bytes from input
    			for(i=0;i<rdln;++i)// 0 to the amount of chars we succesfully read from the input file
    			{
    				buffer[i] ^= pkey[j++]; // XOR with the key
    				if(j==strlen(pkey)) // if j is the strlen of the key
    				{
    					j=0;			// reset it to 0
    				}
    			}
    			fwrite(buffer, sizeof(*buffer), rdln, output); // XOR'd buffer -> output file
    		} while(rdln==sizeof(buffer)); // while characters read == size of the buffer(64)
    	}
    	fclose(input); // close the input file
    	fclose(output); // close the output file
    }
    using unsigned char fixed the issues.
    signed char can contain values between -128 to +127
    unsigned char can contain values between 0 and 256 which is what we want.
    Ah we-a blaze the fyah, make it bun dem!

  7. The Following User Says Thank You to Hell_Demon For This Useful Post:

    why06 (12-12-2009)

  8. #21
    zhaoyun333's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Posts
    396
    Reputation
    11
    Thanks
    1,125
    Plain string: Himynameismike
    Key: hi
    Encrypted string:   bunch of random symbols which for soem reason dosent let me c&p
    There are five possible operations for any army. If you can fight, fight; if you cannot fight, defend; if you cannot defend, flee; if you cannot flee, surrender; if you cannot surrender, die." - Sima Yi

  9. #22
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    I will try this out when I have time. Unfortunately working on a paper now and preparing for finals, but the unsigned thing might be the fix.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  10. #23
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by why06 View Post
    I will try this out when I have time. Unfortunately working on a paper now and preparing for finals, but the unsigned thing might be the fix.
    it is, the code I posted on the last page works fine for me(even able to encrypt and decrypt a 10mb MP3 file without problems )
    Ah we-a blaze the fyah, make it bun dem!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. THIS IS HOW YOU GET YOUR CA TO WORK 100%
    By tyler911 in forum Combat Arms Help
    Replies: 15
    Last Post: 10-30-2009, 09:45 PM
  2. this is for anyone who cant get the aimbot to work and has AVG
    By jmonking in forum Combat Arms Europe Hacks
    Replies: 8
    Last Post: 09-11-2009, 04:51 AM
  3. STICKY THIS!!! ALL NOOBS WHO CANT GET CA HACKS TO WORK OR DC IN GAME COME HERE!!!!
    By Jacobas in forum Suggestions, Requests & General Help
    Replies: 1
    Last Post: 01-02-2009, 09:48 AM
  4. This should help you NOT get D/C anymore.
    By Tinnytim in forum Combat Arms Hacks & Cheats
    Replies: 18
    Last Post: 12-23-2008, 07:57 PM
  5. This should help you NOT get D/C anymore.
    By Tinnytim in forum Combat Arms Hacks & Cheats
    Replies: 6
    Last Post: 12-23-2008, 07:46 PM