Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-26-2013, 11:28 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
String encryption in GS3

My last attempts weren't very secure, so I thought of a new method.
Personally I think this is semi-secure, or at least harder to crack than my last method.
The only flaw of it, the key must be at least 10 in length and can't have any repeated characters.
From what I can tell, this method is called "hashing".
PHP Code:
//#GS3
function onCreated():void{
  var 
str:string "abcdefghijklmnopqrstuvwxyz";
  var 
cat:string this.Enc(str"!:#$%^&*()");
  echo(
"Encrypted: "@cat);
  var 
dog:string this.Dec(cat"!:#$%^&*()");
  echo(
"Decrypted: "@dog);
}
function 
Enc(txt:stringkey:string):string{
  var 
str:string "";
  var 
i:number;
  var 
j:number;
  for(
0txt.length(); ++){
    var 
letter:string txt.charat(i);
    var 
char:string getascii(letter);
    
char = (char.length()>2?char:0@char);
    var 
enc:string "";
    for(
03++){
      var 
l:string char.charat(j);
      var 
e:string key.charat(l);
      
enc @= e;
    }
    
str @= enc;
  }
  return (
str);
}
function 
Dec(txt:stringkey:string):string{
  var 
txt:string = (txt);
  var 
str:string "";
  var 
i:number;
  var 
j:number;
  for(
0txt.length(); += 3){
    var 
group:string txt.substring(i, +3);
    var 
dec:string "";
    for(
03++){
      var 
letter:string group.charat(j);
      var 
num:number key.pos(letter);
      
dec @= num;
    }
    
str @= char(dec);
  }
  return 
str;

Encrypting the alphabet using this method produces the string:
!)*!)(!)):!!:!::!#:!$:!%:!^:!&:!*:!(:!)::!:::::#:: $::%::^::&::*::(::):#!:#::##
The last method, you could crack by trying 30 or so possible combinations, where as this one would require you to try a mass amount of combinations that you wouldn't want to have to go through and try and find the one that looks like something useful.
Also I think due to the maxlooplimit, the maximum length of the string would be 3,333.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 07-26-2013 at 12:16 PM..
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 01:48 PM.


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