Difference between revisions of "Password Generator"

From Second Life Wiki
Jump to navigation Jump to search
(This is an over-complicated, semi-complex password generator, which goes through multiple steps.)
 
Line 1: Line 1:
{{LSL Header}}
I'm new at contributing content to the wiki, so if I did something wrong, feel free to fix it.
I'm new at contributing content to the wiki, so if I did something wrong, feel free to fix it.
 
<lsl>
{{LSL Header}}
//              The most pointless code ever. Completely over-done for such a simple purpose.
//              The most pointless code ever. Completely over-done for such a simple purpose.
//              Syntrax Canucci
//              Syntrax Canucci
Line 45: Line 45:
   touch_start(integer r){BuildPassword();}
   touch_start(integer r){BuildPassword();}
}
}
</lsl>
{{LSLC|Library|Password Generator}}

Revision as of 21:56, 5 June 2009

I'm new at contributing content to the wiki, so if I did something wrong, feel free to fix it. <lsl> // The most pointless code ever. Completely over-done for such a simple purpose. // Syntrax Canucci // Attribution — You must attribute the work in the manner specified by the author // or licensor (but not in any way that suggests that they endorse you or your use of the work). // Noncommercial — You may not use this work for commercial purposes. // Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting // work only under the same or similar license to this one. // http://creativecommons.org/licenses/by-nc-sa/3.0/


list gChars = ["A","B","C","D","E","F","G","H","I","J",

              "K","L","M","N","O","P","Q","R","S","T",
              "U","V","W","X","Y","Z","-","1","2","3",
              "4","5","6","7","8","9","0","-","!","@",
              "#","$","%","^","&","*","(",")","~","_"];

string gPassword; BuildPassword(){

   integer i;
   integer nLength = llRound(llFrand(20)+5);
   llSetText("Building password...",<1,1,1>,1);
   while(llStringLength(gPassword) < nLength){
       i = llRound(llFrand(1));
       if(i == 1){gPassword = gPassword+llToLower(llList2String(gChars,llRound(llFrand(llGetListLength(gChars)))));}
       else{gPassword = gPassword+llToUpper(llList2String(gChars,llRound(llFrand(llGetListLength(gChars)))));}
   }
   integer churn;
   for(churn=0;churn<5;churn++){ gPassword = gPassword + llStringToBase64(gPassword);}
   gPassword = llStringToBase64(gPassword);
   while(llStringLength(gPassword) > llRound(llFrand(20))){
       integer cut = llRound(llFrand(llStringLength(gPassword)/2));
       gPassword = llDeleteSubString(gPassword,cut,cut+llRound(llFrand(5)));
   }
   list slice;
   while(llStringLength(gPassword) > 0){
       slice = slice+llGetSubString(gPassword,0,0);
       gPassword = llDeleteSubString(gPassword,0,0);
   }
   gPassword = llDumpList2String(llListRandomize(slice,1),"");
   llSetText((string)llStringLength(gPassword)+" characters long\n"+gPassword,<1,1,1>,1);llSay(0,gPassword);gPassword="";

} default{

  touch_start(integer r){BuildPassword();}

} </lsl>