I'm writing an encryption program and it's being really cool. Every letter got its own number like: A=606, B= 901... I wrote the Encryption Function without any problem but Decryption Function is not working. I wrote it,too and I definitely think it's gotta work out but it isn't. It is making empty the string that it's gotta be decrypted. Here is the code:
STRING* c_sifre(STRING* yazi)
{
STRING* temp = "#100";
STRING* cozuldu = "#100"; // the final decrypted string
char* karakter;
var a = 1;
var deger = str_len(yazi)/3;
var sayi;
karakter = _chr(yazi);
while(a<=deger)
{
str_cpy(temp,yazi);
str_trunc(temp,3*(deger-a));
sayi = str_to_num(temp);
karakter[a] = c_alfabe(sayi);
str_clip(yazi,3);
a++;
}
str_cpy(cozuldu,_str(karakter));
return cozuldu;
}
function main()
{
STRING* sifrelenecek="Hey, what's going on?"; // the string that is going to be encrypted
STRING* sifrelendi1="#100"; // encrypted string
var dosya = file_open_write ("AA.txt");
while(1)
{
if(key_w==1) { while(key_w) wait(1); str_cpy(sifrelendi1,s_sifre(sifrelenecek));
file_str_write(dosya,sifrelendi1); str_cpy(sifrelenecek,c_sifre(sifrelendi1));
file_str_write(dosya,sifrelenecek);}
if(key_esc==1) { sys_exit(""); }
wait(1);
}
}
s_sifre is the encryption function and it hasn't got any problem.
c_sifre is the decryption function and it is not working.
Thanks for helping...