Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PasswordManager{
- public $username = '';
- public $password = '';
- protected $encryptedPassword = '';
- function Form(){
- $output = "<h2>Password Manager</h2><form id='password-form' action='' method='POST' >
- <p><label>Username<span class='required'>*</span> </label><input class='text-field' type='text' name='txtusername' /></p>
- <p><label>Password<span class='required'>*</span> </label><input class='text-field' type='text' name='txtpassword' /></p>
- <p><input type='submit' value='New user' class='submit-button' /></p>
- <p><input type='submit' value='Validate Password' class='vp-button' /></p>
- </form>
- </body>
- </html>";
- return $output;
- }
- protected function encrypt($password, $encryptedPassword) {
- $encryptedPassword = hash('md5', $password);
- return $encryptedPassword;
- }
- protected function verifyPassword($username, $password) {
- }
- function validatePassword($password) {
- $error = "";
- if (!preg_match('/\s/', $password)) {
- $error .= "<p class='error message'>The password must not contain any whitespace.</p>";
- echo $error;
- } elseif (strlen($password) <6) {
- $error .= "<p class='error message'>The password must be at least 6 characters long.</p>";
- echo $error;
- } elseif (!preg_match('/[0-9][\W]/', $password)) {
- $error .= "<p class='error message'>The password must have at least one digit and symbol.</p>";
- echo $error;
- } elseif (!preg_match('/[A-Z][a-z]/', $password)) {
- $error .= "<p class='error message'>The password must contain at least one uppercase and at least one lowercase letter.</p>";
- echo $error;
- }
- return true;
- }
- function setNewPassword($post_array) {
- $myfile = fopen("password.txt", "w");
- fwrite($myfile, $post_array["txtusername"]);
- fwrite($myfile, md5(post_array["txtpassword"]));
- fclose($myfile);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement