Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-17-2008, 12:24 AM
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
XOR Encryption

I'm not sure if anyone has done this before, but I was rather bored so I made a XOR Encryption function with my own additions to get rid of the parts of the ASCII character set that aren't really shown in Graal.

PHP Code:
/*Paramters:
s - string to be encrypted
usechars - boolean determining whether or not it changes ascii values into characters.
key - Encryption key. (Optional)  If left NULL it replaces with the default. s must be shorter or the same length as the encryption key.
*/
public function XOREncrypt(susecharskey) {
  if (
key == NULL)
    
key "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
temp.replace "-";
  if (
s.length() <= key.length()) {
    
temp.out "";
    for (
i=0i<s.length(); i++) {
      
temp.getascii(s.charat(i)) xor getascii(key.charat(i));
      if (
usechars) {
        if (
temp.32 && temp.!= 127) {
          
temp.char(temp.a);
          if (
temp." ")
            
temp.temp.replace;
        }
        else 
temp.temp.replace;
      }
      
temp.out @= temp.a;
    }
    return 
temp.out;
  }
  else
    return 
"String too long. (Limit " key.length() @ ")";    

Example:
PHP Code:
XOREncrypt("A nice cat"trueNULL); 
Which will return "-b--&#g+(>"

From what I hear, this method is hard, if not impossible to decrypt, and it's rather simple.
__________________

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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.