Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Encrypting Program - A Problem On Decryption [Solved] #239772
12/07/08 08:12
12/07/08 08:12
Joined: Jul 2008
Posts: 23
Turkey
H
Hatean Offline OP
Newbie
Hatean  Offline OP
Newbie
H

Joined: Jul 2008
Posts: 23
Turkey
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:

Quote:
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...

Last edited by Hatean; 12/07/08 15:00.

The Life Game is disgustingly bad but the graphics and reality are extremely cool...
Re: Encrypting Program - A Problem On Decryption [Solved] [Re: Hatean] #239807
12/07/08 15:02
12/07/08 15:02
Joined: Jul 2008
Posts: 23
Turkey
H
Hatean Offline OP
Newbie
Hatean  Offline OP
Newbie
H

Joined: Jul 2008
Posts: 23
Turkey
Problem has been solved. Here is the solving:
Code:
STRING* c_sifre(STRING* yazi)
{
	STRING* temp = "#100";
	STRING* cozuldu = "#100";
	char* karakter;
	var a = 1;
	var deger = str_len(yazi)/3;
	var sayi;
	
	karakter = malloc(sizeof(char)*(deger+1));

	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;
}


Problem is solved by Quadraxas. Thanks to him...


The Life Game is disgustingly bad but the graphics and reality are extremely cool...

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1