Difference between revisions of "Password Generator"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{LSL Header}}
{{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>
<source lang="lsl2">
//              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>
</source>
 
This does the same thing, just with some extra steps for more randomizing, it also displays what it has built, and what it is building from. I like it better. =D
Password Generator 2.0
<source lang="lsl2">
//              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","-","!","@",
              "#","$","%","^","&","*","(",")","~","_"];
list gSlice;
string gPassword;
Text(){llSetText("Building Password...\nCurrent State:\n["+llDumpList2String(gSlice,"],[")+"]\n"+gPassword,<1,1,1>,1);}
BuildPassword(){
    integer i;
    integer nLength = llRound(llFrand(20)+5);
    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)))));}
        Text();
    }
    integer churn;
    for(churn=0;churn<5;churn++){gPassword = gPassword + llStringToBase64(gPassword);Text();}
    gPassword = llStringToBase64(gPassword);
    while(llStringLength(gPassword) > llRound(llFrand(20))){
        integer cut = llRound(llFrand(llStringLength(gPassword)/2));
        gPassword = llDeleteSubString(gPassword,cut,cut+llRound(llFrand(5)));
        Text();
    }
    gSlice = [];
    while(llStringLength(gPassword) > 0){gSlice = gSlice+llGetSubString(gPassword,0,0);gPassword = llDeleteSubString(gPassword,0,0);Text();}
    gPassword = llStringToBase64(llDumpList2String(llListRandomize(llListRandomize(llListRandomize(gSlice,1),1),1),""));
    while(llStringLength(gPassword) > llRound(llFrand(20))){
        integer cut = llRound(llFrand(llStringLength(gPassword)/2));
        gPassword = llDeleteSubString(gPassword,cut,cut+llRound(llFrand(5)));
        Text();
    }
    gSlice=[];
    while(llStringLength(gPassword) > 0){gSlice = gSlice+llGetSubString(gPassword,0,0);gPassword = llDeleteSubString(gPassword,0,0);Text();}
    gPassword = llDumpList2String(llListRandomize(gSlice,1),"");
    llSetText((string)llStringLength(gPassword)+" characters long\n"+gPassword,<1,1,1>,1);llSay(0,gPassword);gPassword="";
}
default{
  touch_start(integer r){BuildPassword();}
}
</source>
{{LSLC|Library|Password Generator}}
{{LSLC|Library|Password Generator}}

Latest revision as of 07:23, 25 January 2015

I'm new at contributing content to the wiki, so if I did something wrong, feel free to fix it.

//              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();}
}

This does the same thing, just with some extra steps for more randomizing, it also displays what it has built, and what it is building from. I like it better. =D Password Generator 2.0

//              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","-","!","@",
               "#","$","%","^","&","*","(",")","~","_"];
list gSlice;
string gPassword;
Text(){llSetText("Building Password...\nCurrent State:\n["+llDumpList2String(gSlice,"],[")+"]\n"+gPassword,<1,1,1>,1);}
BuildPassword(){
    integer i;
    integer nLength = llRound(llFrand(20)+5);
    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)))));}
        Text();
    }
    integer churn;
    for(churn=0;churn<5;churn++){gPassword = gPassword + llStringToBase64(gPassword);Text();}
    gPassword = llStringToBase64(gPassword);
    while(llStringLength(gPassword) > llRound(llFrand(20))){
        integer cut = llRound(llFrand(llStringLength(gPassword)/2));
        gPassword = llDeleteSubString(gPassword,cut,cut+llRound(llFrand(5)));
        Text();
    }
    gSlice = [];
    while(llStringLength(gPassword) > 0){gSlice = gSlice+llGetSubString(gPassword,0,0);gPassword = llDeleteSubString(gPassword,0,0);Text();}
    gPassword = llStringToBase64(llDumpList2String(llListRandomize(llListRandomize(llListRandomize(gSlice,1),1),1),""));
    while(llStringLength(gPassword) > llRound(llFrand(20))){
        integer cut = llRound(llFrand(llStringLength(gPassword)/2));
        gPassword = llDeleteSubString(gPassword,cut,cut+llRound(llFrand(5)));
        Text();
    }
    gSlice=[];
    while(llStringLength(gPassword) > 0){gSlice = gSlice+llGetSubString(gPassword,0,0);gPassword = llDeleteSubString(gPassword,0,0);Text();}
    gPassword = llDumpList2String(llListRandomize(gSlice,1),"");
    llSetText((string)llStringLength(gPassword)+" characters long\n"+gPassword,<1,1,1>,1);llSay(0,gPassword);gPassword="";
}
default{
   touch_start(integer r){BuildPassword();}
}