getNumCountFromAlfabet(input[]);
This function returns the count from the first letter of the input string. If I put 'Hi there' in it, it will get from 'H' the value, which is '8':
A=1
B=2
C=3
etc.
The function:
pawn Код:
stock getNumCountFromAlfabet(input[])
{
switch(input[0])
{
case 'a', 'A': return 1;
case 'b', 'B': return 2;
case 'c', 'C': return 3;
case 'd', 'D': return 4;
case 'e', 'E': return 5;
case 'f', 'F': return 6;
case 'g', 'G': return 7;
case 'h', 'H': return 8;
case 'i', 'I': return 9;
case 'j', 'J': return 10;
case 'k', 'K': return 11;
case 'l', 'L': return 12;
case 'm', 'M': return 13;
case 'n', 'N': return 14;
case 'o', 'O': return 15;
case 'p', 'P': return 16;
case 'q', 'Q': return 17;
case 'r', 'R': return 18;
case 's', 'S': return 19;
case 't', 'T': return 20;
case 'u', 'U': return 21;
case 'v', 'V': return 22;
case 'w', 'W': return 23;
case 'x', 'X': return 24;
case 'y', 'Y': return 25;
case 'z', 'Z': return 26;
default: return strval(input[0]);
}
return -1;
}
If it's an integer, it will return that. ('9hi there' will return 9).
I am by the way sure it can be made much easier.
Why did I made this?
I am using djson and Whirlpool. After gmx or something else, any password is good to login, so I made a hash function:
pawn Код:
stock hash(input[])
{
new tmp[2], tmppass[129];
WP_Hash(tmppass, 129, input);
for(new i = 0; i < strlen(tmppass); i++){
switch(tmppass[i]){
case 'a'..'z', 0..9: tmp[0] = ((tmp[0] + getNumCountFromAlfabet(tmppass[i]) [CENSORED])) * getNumCountFromAlfabet(tmppass[i]);
case 'A'..'Z': tmp[0] = ((tmp[0] + getNumCountFromAlfabet(tmppass[i]) [CENSORED])) * (100 + getNumCountFromAlfabet(tmppass[i]));
}
tmp[1] = ([CENSORED]);
}
return [CENSORED];
}
I've censored it so that decrypt is harder. And as you can see, it first encrypts the string to whirlpool, and then I use getNumCountFromAlfabet to get an integer (I could've used that num_hash from dracoblue, but I made my own, I am not sure why).
With this hash,
Hi there! You are very smart if you can decrypt this text. will be:
9371648.
However, I don't know why I posted this, because it's the getNumCountFromAlfabet.
And, please tell it if that function can be improved (something like "return 'a'..'z' = 1..26" or something :P)