Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 08/22/26 08:44
Max Number of Strategies in /Strategy folder
by Martin_HH. 08/17/26 07:54
Pause button for evaluation shell?
by AndrewAMD. 08/13/26 17:16
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 08/10/26 12:46
phantom() not defined in indicators.c
by jcl. 08/07/26 11:45
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (NorbertSz), 2,948 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Student_64151, Koti
19230 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