Jump to content

Password


Berny Bury
 Share

You are about to reply to a thread that has been inactive for 1488 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Set a password for a script ! 

First time we ask a password then encrypt it and set to description Object, Next time only we decrypt from get description of object !

the crypt could store also in notepad

---------------------------------------------

string Crypt="123456789";
string password ="";
string action="";
integer listenHandle;
default
{
    state_entry()
    {
        listenHandle = llListen(10, "", "llDetectedKey(0)", "");
        
    }

    touch_start(integer total_number)
    {
        if(llGetObjectDesc()=="EMPTY")
        {
             llTextBox( llDetectedKey(0),"Please enter your Password (to define)",10);
             action = "password";
        } 
        
       else
        {
             llTextBox( llDetectedKey(0),"Please enter your Password ...",10);
             action = "verify password";
          
          }  
          
    }
     listen(integer channel, string name, key id, string message)
    {
       
         llSay(0,"MESSAGE IS "+ message);
        if (action == "password")
        {
            password = message;
            string datacrypt = llXorBase64StringsCorrect(llStringToBase64(password), llStringToBase64(Crypt));
            llSetObjectDesc(datacrypt);
                    
        }
         if (action == "verify password")
        {
            password = message;
           llSay(0,"pass s "+password);
            string verify = llBase64ToString(llXorBase64StringsCorrect(llGetObjectDesc(), llStringToBase64(Crypt)));
            if (verify == password)
            {
                 llSay(0,"OKAY "+password);
            }
            else 
             llSay(0,"Bad pass "+password);
                    
        }
    }
}

Link to comment
Share on other sites

The wiki suggests using llXorBase64 instead.  I have never had reason to use it myself, but that sounds like a good way to go.  There's been some good discussion about encryption in this forum over the years, so you ought to be able to get other ideas by digging round in the archives.  There are also a couple of interesting scripts in the wiki's  LSL Library (not this forum's library).  For many years, I have used a pair of encryption/decryption routines that I think were written by Strife Onizuka but I have long lost the real attribution, so I can't be sure:

//routine to hash the message before sending it

string messageWithHash(string message,key id)
{
    return(message + "\n" + llSHA1String(message+passPhrase+(string)id));
}


//routine to decode the message on receipt

string checkSum(string message,key id)
{
    string hash;
    integer pos = llStringLength(message);
    while(--pos >= 0) {
        if(llGetSubString(message,pos,pos) == "\n")
        {
            hash = llGetSubString(message,pos+1,-1);
            message = llGetSubString(message,0,pos - 1);
            if(llSHA1String(message+passPhrase+(string)id) == hash)
            {
                // The checksum matches. This object passes the test
                // and is good. Return the valid message.
                return(message);
            }
            else
            {
                // The checksum does not match. Return an empty string.
                return("");
            }
        }
    }
    // No check sum was found. Return an empty string.
    return("");
}

The passPhrase is whatever password you decide to use for the application
 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1488 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...