Hi, haven't been active on the forums in a while but I was looking for some feedback, the last time I attempted a cipher, it didn't use a key and was pretty basic. Here is my latest attempt, what do you guys/gals think?
Uses:
To encrypt sensitive player attributes.
To encrypt any string on the server really.
Pros:
Makes strings semi-secure.
Cons:
Makes strings long.
PHP Code:
/*
The logic of this encryption is basically
Get a key/salt and get a numerical value
from the string, so to get that we convert it
to numbers by getting each ascii value of
each character, this gives us an integer
that we can use as a salt.
Once we have out key, we then get each character
of the string to encrypt, get the ascii of it
which returns an integer, plus that with the salt
and add it to an array sort of thing with a seperator
chacarter.
We also base64 it both ways to make it look more neat.
*/
//Seperator character.
const sep = ".";
function Encrypt(string, key){
temp.key = RealKey(key);
temp.str;
for(temp.i = 0; i < string.length(); i ++){
temp.letter = string.substring(i, +1);
temp.letter = getascii(temp.letter);
temp.str = temp.str@temp.letter+key@sep;
}
return base64encode(temp.str);
}
function Decrypt(string, key){
temp.string = base64decode(string);
temp.key = RealKey(key);
temp.str;
temp.tok = string.tokenize(sep);
for(temp.i = 0; i < tok.size(); i ++){
temp.letter = tok[i];
temp.letter = char(temp.letter-key);
temp.str = temp.str@letter;
}
return temp.str;
}
function RealKey(key){
temp.char;
for(temp.i = 0; i < key.length(); i ++){
temp.letter = key.substring(i, +1);
temp.code = getascii(temp.letter);
temp.char += temp.code;
}
return int(temp.char/2);
}