SA-MP Forums Archive
String manipulation question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: String manipulation question (/showthread.php?tid=630093)



String manipulation question - Seifspeed - 08.03.2017

Can someone please explain to me what this does? (It seems illogical to me when I try to read it like a python script, I haven't done Pawn in a long time).
Also, this seems to return numbers. Doesn't string[x] return the indexed letter?

Thanks in advance!

Код:
public test(string[])
{
	for(new x=0; x < strlen(string); x++)
	{
		string[x] += (3^x) * (x % 15); //This line specifically

		if(string[x] > (0xff))
		{
			string[x] -= 256;
		}
	}
	return 1;
}



Re: String manipulation question - Toroi - 08.03.2017

Lurking and bumping for the explanation, this seems an interesting thread.

Is this some kind of anti spam function? I can't understand shit, I never went to school.


Re: String manipulation question - DRIFT_HUNTER - 09.03.2017

Well from what i can see it doesn't do anything. It only returns 1 and string is not passed by reference so changes are not saved.

But if we take it as a working function then it looks like some kind of encryption that can be reversed. Actually encryption is a bit strong word, i would rather say string obfuscation.


Re: String manipulation question - Nero_3D - 09.03.2017

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
It only returns 1 and string is not passed by reference so changes are not saved.
Arrays and varargs are always passed by reference


Re: String manipulation question - NaS - 09.03.2017

Could be a conversion for different character sets, target could be ANSI (256 chars, would match - just a guess tho).

The formula may look weird but could be simplified from the original.

EDIT: Scratch that, it's a simple form of encryption.

It just offsets each character by a number calculated from its position. Can be "decrypted" again by doing

Код:
string[x] -= (3^x) * (x % 15);

if(string[x] < 0) string[x] += 256;