View Single Post
  #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