Quote:
Originally Posted by Loriel
You could use an additional Base64 encoding to make the encrypted string printable.
|
Ah, true, I hadn't thought of that.
PHP Code:
public function XOREncrypt2(s, key) {
if (key == NULL)
key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
temp.out = "";
if (s.length() <= key.length()) {
for (i=0; i<s.length(); i++) {
temp.a = getascii(s.charat(i)) xor getascii(key.charat(i));
temp.out @= char(temp.a);
}
return base64encode(temp.out);
}
else
return "String too long. (Limit " @ key.length() @ ")";
}
This seems to work rather well, actually. Short and sweet.