Am I?
Let's say 533.
This will be made into 002, which is 2 as an integer, now when you decrypt it, it will be 5.
Next time, you shouldn't miss reading such lines:
Of course, only if it is stored as an integer.
This should show you exactly what I mean:
Code:
#include <stdio.h>
int encrypt(int *data){
int res=0,x=*data,num;
while(x>0){
res*=10;
num=x%10;
res+=(num+7)%10;
x/=10;
}
*data=res;
return 0;
}
int decrypt(int *data){
int res=0,x=*data,num;
while(x>0){
res*=10;
num=x%10;
res+=(num+3)%10;
x/=10;
}
*data=res;
return 0;
}
int main(){
char buffer[2];
int num=5631;
printf("Number: %i\n",num);
encrypt(&num);
printf("Encrypted: %i\n",num);
decrypt(&num);
printf("Decrypted: %i\n",num);
num=646579856;
printf("Number: %i\n",num);
encrypt(&num);
printf("Encrypted: %i\n",num);
decrypt(&num);
printf("Decrypted: %i\n",num);
fgets(buffer,2,stdin);
return 0;
}
Got it?