Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool

    Problem decrypting [Solved]

    Hi all, i'm trying to do a simple crypter for strings. With the Crypt function i have no problem:
    Code:
    int lunghezza;               //As globals
    double valori[20];           
    
    char* AltCrypt(char* string)
    {
    	lunghezza = strlen(string);
    	char* tempstring = new char[lunghezza + 1];
    
    	for (int j=0; j<lunghezza; j++)
    	{	 valori[j] = atof(&string[j]);
    		
    		tempstring[j] = string[j] + string[j+1];
    		j++;
    	}
    
    	tempstring[lunghezza/2] = 0;
    	return tempstring;
    }
    In the console i print the crypted string and it's all good. When i try to Decrypt it, the console doesn't print me anything. That's my function to Decrypt:

    Code:
    char* AltDecrypt(char* string)
    {
    	lunghezza = strlen(string);
    	
    	char* tempstring = new char[(lunghezza*2) + 1];
    
    	for (int j=0; j<lunghezza; j++)
    	{	
    		tempstring[j] = valori[j];
    		tempstring[j+1] = string[j] - valori[j];
    		
    	}
    
    	tempstring[lunghezza*2] = 0;
    	return tempstring;
    }
    And finally this is how i call them in the main:

    Code:
            cout<<"Alt-crypting: Hi man!"<<endl;
    	char* done = AltCrypt("Hi man!");
    	cout<<done;
    	cout<<"\n\nAlt Decrypting: "<<AltDecrypt(done);
    That's the result:

    I tryed to follow the debug step by step with the breakpoints but when the compiler arrives at the Decrypt function it stops and asks me for a file(ftol2.asm). I tryed to google it but all says that it's not a problem, u can easily avoid it by put the breakpoint after that instruction. So, can anyone help me? ty in advance

  2. #2
    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
    Re-read over those two functions and try doing them in your head with say 2 numbers, they don't make sense .-.
    Ah we-a blaze the fyah, make it bun dem!

  3. #3
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by Hell_Demon View Post
    Re-read over those two functions and try doing them in your head with say 2 numbers, they don't make sense .-.
    for me it has sense .-. i only add the j element with the next one so i can have a crypted string with half size of the original. maybe i have to explain the whole code :\ so u all can understand better

  4. #4
    Nico's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Germany :D
    Posts
    15,918
    Reputation
    1121
    Thanks
    8,617
    Quote Originally Posted by Sixx93 View Post
    for me it has sense .-. i only add the j element with the next one so i can have a crypted string with half size of the original. maybe i have to explain the whole code :\ so u all can understand better
    But you change the number of the next thing so if you decrypt it, it uses another number.

  5. #5
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by Nicdel View Post
    But you change the number of the next thing so if you decrypt it, it uses another number.
    no, because the original one is stored in the array

  6. #6
    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
    crypt has 2x j++
    Ah we-a blaze the fyah, make it bun dem!

  7. #7
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by Hell_Demon View Post
    crypt has 2x j++
    yes, because the j+1 element is added with the j's one, so i have to jump of 2 steps

  8. #8
    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
    Make an array of a few numbers and check the array values after each step, you'll probably figure out whats going wrong then..
    Ah we-a blaze the fyah, make it bun dem!

  9. #9
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by Hell_Demon View Post
    Make an array of a few numbers and check the array values after each step, you'll probably figure out whats going wrong then..
    i worked on my 2 functions, i changed something that could be wrong, now i get a decrypted string, but it's not right, it isn't the original. these are the new ones:

    Code:
    int lunghezza;
    int valori[20];
    
    char* AltCrypt(char* string)
    {
    	lunghezza = strlen(string);
    	char* tempstring = new char[lunghezza + 1];
    
    	for (int j=0; j<lunghezza; j+=2)
    	{	
    		valori[j] = atoi(&string[j]);
    		tempstring[j] = string[j] + string[j+1];
    	}
    
    	tempstring[lunghezza/2] = 0;
    	return tempstring;
    }
    
    char* AltDecrypt(char* string)
    {
    	char* tempstring = new char[lunghezza+1];
    
    	for (int j=0; j<lunghezza; j+=2)
    	{	
    		itoa(valori[j],&tempstring[j],10);
    		tempstring[j+1] = string[j] - tempstring[j];
    	
    	}
    
    	tempstring[lunghezza] = 0;
    	return tempstring;
    }

  10. #10
    ғᴜᴋᴏᴊʀ's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    1,557
    Reputation
    87
    Thanks
    141
    My Mood
    Inspired
    Quote Originally Posted by Sixx93 View Post
    i worked on my 2 functions, i changed something that could be wrong, now i get a decrypted string, but it's not right, it isn't the original. these are the new ones:

    Code:
    int lunghezza;
    int valori[20];
    
    char* AltCrypt(char* string)
    {
    	lunghezza = strlen(string);
    	char* tempstring = new char[lunghezza + 1];
    
    	for (int j=0; j<lunghezza; j+=2)
    	{	
    		valori[j] = atoi(&string[j]);
    		tempstring[j] = string[j] + string[j+1];
    	}
    
    	tempstring[lunghezza/2] = 0;
    	return tempstring;
    }
    
    char* AltDecrypt(char* string)
    {
    	char* tempstring = new char[lunghezza+1];
    
    	for (int j=0; j<lunghezza; j+=2)
    	{	
    		itoa(valori[j],&tempstring[j],10);
    		tempstring[j+1] = string[j] - tempstring[j];
    	
    	}
    
    	tempstring[lunghezza] = 0;
    	return tempstring;
    }
    I suggest just listening to Wesley, he knows what he's talking about.


    [IMG]https://i186.photobucke*****m/albums/x253/Rypleys/MNC/biohazard2.jpg[/IMG]

    MPGH in 5 words:

    Quote Originally Posted by ZEROProJect View Post
    1 in a million community

  11. #11
    zhaoyun333's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Posts
    396
    Reputation
    11
    Thanks
    1,125
    Many problems in your code.
    First off
    Code:
    valori[j] = atoi(&string[j]);
    This dosen't do anything at all. Try outputting it in your code and you'll get 0 everytime. Do you know atoi does? It changes a STRING to an integer and I dont even know what you're trying to do.

    2nd issue
    Code:
    itoa(valori[j],&tempstring[j],10);
    This piece of code is jsut as useless. itoa takes the value of the first parameter and stores it in a string. However, you're taking valori[j] and trying to store it in the address of the character

    Perhaps if you could try to explain your encryption method we can help you
    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

  12. #12
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,409
    My Mood
    In Love
    No I do not make game hacks anymore, please stop asking.

  13. #13
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by zhaoyun333 View Post
    Many problems in your code.
    First off
    Code:
    valori[j] = atoi(&string[j]);
    This dosen't do anything at all. Try outputting it in your code and you'll get 0 everytime. Do you know atoi does? It changes a STRING to an integer and I dont even know what you're trying to do.

    2nd issue
    Code:
    itoa(valori[j],&tempstring[j],10);
    This piece of code is jsut as useless. itoa takes the value of the first parameter and stores it in a string. However, you're taking valori[j] and trying to store it in the address of the character

    Perhaps if you could try to explain your encryption method we can help you
    i used atoi to get the ascii code of each char but i see that this isn't the right method... anyway my idea is to convert all the chars in the string to the ascii code and create a new (crypted) string wich will have as first char the ascii value equal to the sum of the first and second char of the original; as second the sum of the 3rd and the 4th of the original, etc etc... i used itoa to try to convert the number to the char equivalent in ascii. hope is all clear.

    @flameswor10 ty for your 2 functions, they inspired me for making my ones ( not this ones xD )
    Code:
    struct Command
    {	public:
    		char* string;
    		 bool a_crypted;
    		void Crypt();
    		void Decrypt();
    
    	private:
    		int* RandomNum(int);
    		int* numb;
    		
    };
    
    
    
    int* Command::RandomNum(int times)
    {	int lowest = 0, highest = 65;
    	int* numbers = new int[times+1];
    	for(int j=0; j<times; j++)
    	{
        int random_integer; 
        int range=(highest-lowest)+1; 
            random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
    		numbers[j] = random_integer;
    	}
    	return numbers;
    }
    
    void Command::Crypt()
    {	a_crypted = true;
    	int length = strlen(string);
    	char* tempstring = new char[length + 1];
    	numb = new int[length+1];
    	numb = RandomNum(length);
    
    	for (int j=0; j<length; j++)
    	{
    		int KeyStep = numb[j] + j;
    		tempstring[j] = string[j] + KeyStep;
    		
    	}
    
    	tempstring[length] = 0;
    	string = tempstring;
    }
    void Command::Decrypt()
    {	
    	int length = strlen(string);
    	char* tempstring = new char[length + 1];
    if(a_crypted == false)
    {
    	numb = new int[length+1];
    	numb = RandomNum(length);
    }
    	for (int j=0; j<length; j++)
    	{
    		int KeyStep = numb[j] + j;
    		tempstring[j] = string[j] - KeyStep;
    		
    	}
    
    	tempstring[length] = 0;
    	string = tempstring;
    }
    for a bug of your (again xD) RandomNum function, it works very well i mean, that function works, but it generate every time the same random numbers

    After i did this encryption method i thought i wanted to write a function to crypt a string modifying the length of it, so here they are xD the only problem is that they don't work xD
    Last edited by Sixx93; 08-13-2011 at 05:29 PM.

  14. #14
    zhaoyun333's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Posts
    396
    Reputation
    11
    Thanks
    1,125
    You need to seed the random function:

    Code:
    #include <time.h>
    
    int main(void){
    
    srand(time(NULL));
    
    /*
    blahblah
    */
    
    }
    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

  15. #15
    Sixx93's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    673
    Reputation
    21
    Thanks
    250
    My Mood
    Cool
    Quote Originally Posted by zhaoyun333 View Post
    You need to seed the random function:

    Code:
    #include <time.h>
    
    int main(void){
    
    srand(time(NULL));
    
    /*
    blahblah
    */
    
    }
    no it works very well .-.

Page 1 of 2 12 LastLast

Similar Threads

  1. [Solved] Injector problem solved
    By NinjaKantana in forum CrossFire Help
    Replies: 1
    Last Post: 07-12-2011, 01:40 PM
  2. [Help] Encryption/Decryption [Solved]
    By Lyoto Machida in forum Visual Basic Programming
    Replies: 11
    Last Post: 03-10-2011, 05:07 AM
  3. Offering services to solve hacking problems
    By viperfx in forum Combat Arms Hacks & Cheats
    Replies: 123
    Last Post: 08-19-2008, 07:31 PM
  4. i solve my problem :)
    By D4nny in forum WarRock - International Hacks
    Replies: 2
    Last Post: 08-31-2007, 04:40 AM
  5. Problem Solved...
    By Dave84311 in forum News & Announcements
    Replies: 0
    Last Post: 04-02-2007, 03:22 PM