Thread: XOR Encryption
View Single Post
  #11  
Old 08-17-2008, 10:21 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Loriel View Post
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(skey) {
  if (
key == NULL)
    
key "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
temp.out "";
  if (
s.length() <= key.length()) {
    for (
i=0i<s.length(); i++) {
      
temp.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.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote