PDA

View Full Version : Adding Password Protection


Desmond
10-03-2003, 04:25 PM
<HTML> <HEAD> <TITLE>AutoPlay Media Studio 5.0 Knowledge Base</TITLE> </HEAD> <BODY> <h3>Adding Password Protection</h3> <b>Document ID: IR10097</b> <hr> The information in this article applies to: <ul> <li>AutoPlay Media Studio 5.0 Standard Edition</li> <li>AutoPlay Media Studio 5.0 Professional Edition</li> </ul> <hr> <h3>SUMMARY</h3> <p>This article describes how to make your application password protected.</p> <h3>DISCUSSION</h3> <p> There are many instances requiring the user to be prompted for information that must not be visible on the screen, such as a password. In AutoPlay Media Studio 5.0 this is accomplished by using a Dialog.PasswordInput action.<br> <br> As an example, we will prompt the user for a password at the start of your program, and compare it to a stored value (thereby limiting access to your program to only those who know the password). </p> <ol> <li>To accomplish this, insert the following script in your page's On Show event:<pre><code>-- the 'correct' password
<br />real_password = "password";
<br />
<br />-- prompt the user to enter a password
<br />user_password = Dialog.PasswordInput("Password", "Please enter the password: ", MB_ICONQUESTION);
<br />
<br />-- compare the user's password to the 'correct' password.
<br />-- If the user supplies the wrong password, exit the program.
<br />if real_password ~= user_password then
<br /> Application.Exit();
<br />end</code></pre> This script pops up a dialog box requesting the password. Whatever the user types in this dialog box appears as *******. If the correct password is entered, the program runs normally. If any other password is entered, the program will close.<br> <br> </li> <li> Alternatively, you can have a 'list' of valid passwords. To accomplish this, store your valid passwords in a table (Pro Edition Only) by inserting the following script in your page's On Show event:<pre><code>--assume the user enters a bad password
<br />correct_password = false;
<br />
<br />-- the 'correct' password
<br />real_passwords = {"password", "password2", "3rdPassword"};
<br />
<br />-- prompt the user to enter a password
<br />user_password = Dialog.PasswordInput("Password", "Please enter the password: ", MB_ICONQUESTION);
<br />
<br />-- compare the user's password to the 'correct' password.
<br />for j in real_passwords do
<br /> if real_passwords[j] == user_password then
<br /> correct_password = true;
<br /> end
<br />end
<br />
<br />--if the password was bad, exit
<br />if not correct_password then
<br /> Application.Exit();
<br />end</code></pre> <br> You can also store your password list in a text file, and when your application is run, populate a table with the contents of that text file.</li> </ol> <h3>MORE INFORMATION</h3> <p>For more information please see the following topics in the AutoPlay Media Studio 5.0 help file:</p> <ul> <li><b>Program Reference | Actions | Dialog | Dialog.PasswordInput</b></li> </ul> <p>KEYWORDS: AutoPlay Media Studio 5.0, Password, Protection, Security, Secure </p> <hr> <FONT SIZE=1> Last reviewed: October 3, 2003<br> Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.<br> </FONT> </BODY> </HTML>