Difference between revisions of "Random Password Generator"

From Second Life Wiki
Jump to navigation Jump to search
(New page: Code: <lsl> //Easy Random Password Generator with Password Length. // // - Created by Jor3l Boa - // // Available under the Creative Commons Attribution-ShareAlike 2.5 license // http://cr...)
 
m (<lsl> tag to <source>)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Code:
Code:
<lsl>
<source lang="lsl2">
//Easy Random Password Generator with Password Length.
// Generate Passwords based on String length
//
// Free to use, share and remix.
// - Created by Jor3l Boa -
//
// Available under the Creative Commons Attribution-ShareAlike 2.5 license
// http://creativecommons.org/licenses/by-sa/2.5/
//
// http://sltools.biz


string randomPassword(integer length)
{
    string CharSet = "abcdefghijkmnpqrstuvwxyz23456789";    // omitting confusable characters
    string password;
    integer CharSetLen = llStringLength(CharSet);
    // Note: We do NOT add 1 to the length, because the range we want from llFrand() is 0 to length-1 inclusive


string randomPass(integer length)   {
    while (length--)
     string letters = "abcdefghijkmnopqrstuvwxyz234567890";
     {      
     string rPass;
         integer rand = (integer) llFrand(CharSetLen);
    while(llStringLength(rPass) < length)  {
         password += llGetSubString(CharSet, rand, rand);
         integer rand = llFloor(llFrand(llStringLength(letters)));
         rPass += llGetSubString(letters,rand,rand);
     }
     }
     return rPass;
     return password;
}
}
 
default
default
{
{
     state_entry()
     touch_start(integer num)
     {
     {
         llSay(0,randomPass(10));
         llSay(0, randomPassword(10));
     }
     }
}
}
</lsl>
</source>

Latest revision as of 07:44, 25 January 2015

Code:

// Generate Passwords based on String length
// Free to use, share and remix.

string randomPassword(integer length)
{
    string CharSet = "abcdefghijkmnpqrstuvwxyz23456789";    // omitting confusable characters
    string password;
    integer CharSetLen = llStringLength(CharSet);
    // Note: We do NOT add 1 to the length, because the range we want from llFrand() is 0 to length-1 inclusive

    while (length--)
    {     
        integer rand = (integer) llFrand(CharSetLen);
        password += llGetSubString(CharSet, rand, rand);
    }
    return password;
}
 
default
{
    touch_start(integer num)
    {
        llSay(0, randomPassword(10));
    }
}