10.06.2014, 10:54
(
Последний раз редактировалось Aerotactics; 10.06.2014 в 21:19.
)
GvalWhzoyr
ol Nrebgnpgvpf
Aboutol Nrebgnpgvpf
This was...originally going to be built to write a "coded" or jumbled message, and that's it. I ran into an error I never knew about, and a forum member by the name of Vince helped me through it, and mentioned that 26 of the same line was inefficient. I had to agree, so I got to work compacting it after I said I could probably make a stock for this "jumbler." (https://sampforum.blast.hk/showthread.php?tid=517222) Well those 30 lines were crafted into 8, and this stock can jumble from 1 alphabet, to another alphabet by using a loop within a loop. I can't tell you how excited I was to make it work and to be able to show it to the public.
pawn Код:
stock TinyJumble(str[], alphabet[], alphabet2[])
{//TinyJumble was written and created by Aerotactics
new JumbledString[128];
strins(JumbledString, str, 0);
new i = 0;ILoop:
new j = 0;JLoop:
if(JumbledString[i] == alphabet[j] && JumbledString[i] != '\0'){JumbledString[i] = alphabet2[j]; i++; goto ILoop;}
j++;if(j < 64) {goto JLoop;}
i++;if(i < 128) {goto ILoop;}
return JumbledString;
}
What this does is compare each character in a string to an "alphabet," and if the character matches, change the character to the corresponding character in a second alphabet. This continues for each and every character.
Let's look at the function in an example:
pawn Код:
SCM(playerid, COLOR_WHITE,TinyJumble("This is a String","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba"));
Quote:
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz" "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfed cba" |
Those alphabets do take up a lot of space, so just like defining a color, you can define your alphabets:
pawn Код:
#define ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
#define BACKWARDS "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba"
#define ROT13 "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"
SendClientMessage(playerid, COLOR_WHITE, TinyJumble("This is a String",ALPHABET,BACKWARDS));
What about DE-crypting?
Conveniently, the defined ALPHABET and BACKWARDS as well as ALPHABET and ROT13 are mirrors of each other, A = N & N = A in ROT13. Since that is the case, all you have to do is send the jumbled message back through the same line:
TinyJumble("Guvf vf n Fgevat",ALPHABET,ROT13)
And it will return as This is a String. When the alphabets are not mirrored, all you have to do is reverse the scan order:
TinyJumble("Guvf vf n Fgevat",ROT13,ALPHABET)
Meaning it will take the ROT13 message, and change it to the default ALPHABET.
What is ROT13? Rotation 13 is a rotation between the first 13 letters, and the last 13 letters of the alphabet. It's definitely one of the more simple decodings, meaning if you know it's ROT13, you already know how to decode it.
What else can it do?
You name it. This can be used as a custom hasher (wouldn't recommend it), it can be used as a fictional language, and you can even jumble a jumbled message!
TinyJumble(TinyJumble(string,ALPHABET,ALIEN),ALIEN,SWEAR))
The string is an input string.
The first jumble changes it from the standard alphabet to a custom alphabet ALIEN.
The second jumble changes the ALIEN string to another fictional alphabet SWEAR.
This method is possible, but sometimes, if you jumble more than one alphabet, there's a chance that a letter may be corrupted on the way back through the decrypting.
This stock by default is able use more than just the alphabet. You can use special characters as well, but I would avoid punctuation in your alphabets.
You call this a filterscript?! It's just a stock!
True, but back when it was 30 lines long, it was going to be released as a filterscript. After making it as small as humanly possible, and still able to be read, I used the filterscript it was in for testing. Of course, I'm releasing that filterscript down below. Another reason was because I needed to explain how and why it works. I'm no teacher though, so I apologize if the guide is a bit vague.
How can I write a command to jumble messages?
pawn Код:
#define COLOR_WHITE 0xFFFFFFFF
#define SCM SendClientMessage // easier scripting lol
CMD:jumble(playerid,params[])
{
new string[128];
new alpha[12];
if(sscanf(params,"s[12]s[128]",alpha,string)) return SCM(playerid, COLOR_WHITE, "Usage: /jumble [alphabet] [string]");
if(!strcmp(alpha,"backwards")) SCM(playerid, COLOR_WHITE, TinyJumble(string,ALPHABET,BACKWARDS));
if(!strcmp(alpha,"rot13")) SCM(playerid, COLOR_WHITE, TinyJumble(string,ALPHABET,ROT13));
if(!strcmp(alpha,"vowels")) SCM(playerid, COLOR_WHITE, TinyJumble(string,ALPHABET,VOWELS));
return 1;
}
pawn Код:
CMD:dejumble(playerid,params[])
{
new string[128];
new alpha[12];
if(sscanf(params,"s[12]s[128]",alpha,string)) return SCM(playerid, COLOR_WHITE, "Usage: /dejumble [alphabet] [string]");
if(!strcmp(alpha,"backwards"))return SCM(playerid, COLOR_WHITE, TinyJumble(string,BACKWARDS,ALPHABET));
return 1;
}
Good question! Originally, it was going to be named The Jumbler (as the filterscript name implies), but when I was testing the stock I named it "TinyJumble" and it was more fitting.
Can I take this as my own?
No.
You deserve all the rep in the world!
Not a question, but thanks for your enthusiasm.
Download: Jumbler FS (Mediafire)