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:
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
Re-read over those two functions and try doing them in your head with say 2 numbers, they don't make sense .-.
Originally Posted by Hell_Demon
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
Originally Posted by Sixx93
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.
Originally Posted by Nicdel
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
crypt has 2x j++
Originally Posted by Hell_Demon
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
Make an array of a few numbers and check the array values after each step, you'll probably figure out whats going wrong then..
Originally Posted by Hell_Demon
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:
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:
I suggest just listening to Wesley, he knows what he's talking about.
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
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 )
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
You need to seed the random function:
Code:
#include <time.h>
int main(void){
srand(time(NULL));
/*
blahblah
*/
}
Originally Posted by zhaoyun333
You need to seed the random function:
Code:
#include <time.h>
int main(void){
srand(time(NULL));
/*
blahblah
*/
}