コード例 #1
0
 public function generate($amount, $params = array())
 {
     $this->params = array_merge($this->params, $params);
     $emailGenerator = new EmailGenerator();
     $passwordGenerator = new PasswordGenerator();
     $emails = $emailGenerator->generate($amount, $params);
     $params['unique'] = false;
     $passwords = $passwordGenerator->generate($amount, $params);
     for ($i = 0; $i < $amount; $i++) {
         $password = $passwords[$i];
         if ((bool) $this->params['hashed_password']) {
             // password should be hashed
             switch ($this->params['hash_function']) {
                 case 'sha1':
                     $password = sha1($password);
                     break;
                 case 'md5':
                 default:
                     $password = md5($password);
             }
         }
         $usercredential = str_replace('{email}', $emails[$i], $this->params['pattern']);
         $usercredential = str_replace('{password}', $password, $usercredential);
         $this->fake_data[] = $usercredential;
     }
     return $this->fake_data;
 }
コード例 #2
0
function GenerateNewPassword($payload)
{
    $passwordGenerator = new PasswordGenerator();
    echo 'test';
    $passwordGenerator->SetCurrentEmail($payload);
    if ($passwordGenerator->GenerateNewPassword()) {
        echo 'true';
    } else {
        echo 'false';
    }
}
コード例 #3
0
 /**
  * Generate and update User with new password.
  * @param User $user
  * @return string
  */
 private function updateUserPassword(User $user)
 {
     $newPassword = PasswordGenerator::generate();
     $newPasswordHash = HashGenerator::generateMD5($newPassword);
     $user->setPassword($newPasswordHash);
     DAOFactory::getUserDAO()->save($user);
     return $newPassword;
 }
コード例 #4
0
ファイル: pastebin.php プロジェクト: jorik041/pastebin
function commit_post($text, $jsCrypt, $lifetime_seconds, $short = false)
{
    do {
        $urlKey = PasswordGenerator::getAlphaNumericPassword($short ? 8 : 22);
    } while (retrieve_post($urlKey) !== false);
    $id = get_database_id($urlKey);
    $encryptionKey = get_encryption_key($urlKey);
    $iv = mcrypt_create_iv(IV_BYTES, MCRYPT_DEV_URANDOM);
    $encrypted = SafeEncode($iv . mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $encryptionKey, $text, MCRYPT_MODE_CBC, $iv));
    $jsCrypted = $jsCrypt ? 1 : 0;
    $time = (int) (time() + $lifetime_seconds);
    mysql_query("INSERT INTO pastes (token, data, time, jscrypt) \n        VALUES('{$id}', '{$encrypted}', '{$time}', '{$jsCrypted}')");
    return $urlKey;
}
コード例 #5
0
ファイル: WebUser.php プロジェクト: niranjan2m/Voyanga
 public function createNew($email)
 {
     $newUser = new FrontendUser();
     $newUser->username = $email;
     $newUser->email = $email;
     $password = PasswordGenerator::createSimple();
     $newUser->password = $password;
     try {
         if ($newUser->save()) {
             EmailManager::sendUserInfo($newUser, $password);
         }
     } catch (Exception $e) {
         return $this->checkIfExists($email);
     }
     return $newUser;
 }
コード例 #6
0
ファイル: ClaveForm.php プロジェクト: JeffreyMartinezEiso/lrv
 public function validateExist($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $objUsuario = Usuario::model()->find(array('condition' => "identificacionUsuario=:identificacion", 'params' => array(':identificacion' => $this->identificacionUsuario)));
         if ($objUsuario === null) {
             $this->addError($attribute, $this->getAttributeLabel($attribute) . ' no existe.');
         } else {
             if ($objUsuario->activo != 1) {
                 $this->addError($attribute, $this->getAttributeLabel($attribute) . ' no activo.');
             } else {
                 $this->nuevaClave = PasswordGenerator::generatePass(8);
                 $objUsuario->clave = $objUsuario->hash($this->nuevaClave);
                 if (!$objUsuario->save()) {
                     $this->addError($attribute, ' Error al cambiar clave, intente de nuevo.');
                 }
             }
         }
     }
 }
コード例 #7
0
ファイル: Password.php プロジェクト: aslijiasheng/ciFramework
 public function create($min_length = 10, $max_length = null, $characters = null)
 {
     $min_length = (int) $min_length;
     if ($min_length < 4) {
         $min_length = 4;
     }
     if ($max_length === null) {
         $max_length = $min_length;
     } else {
         $max_length = (int) $max_length;
         if ($max_length < $min_length) {
             $max_length = $min_length;
         }
     }
     $length = mt_rand($min_length, $max_length);
     $characters = (string) $characters;
     if ($characters == '') {
         $characters = "!#\$%+-0123456789=?@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
     }
     return PasswordGenerator::getCustomPassword(str_split($characters), $length);
 }
コード例 #8
0
 private function createGuestUser($email, $name, $propertyId)
 {
     $newUser = new User();
     $newUser->setAttribute('email', $email);
     $newUser->setAttribute('firstname', $name);
     $password = PasswordGenerator::generatePassword();
     $newUser->setAttribute('password', $password);
     $newUser->setAttribute('property_id', $propertyId);
     $newUser->setAttribute('createdDate', new CDbExpression('NOW()'));
     $tutorialModel = new TutorialModel();
     $tutorialModel->setAttributes(array('gallery' => 1, 'guest_book' => 1, 'house_rules' => 1, 'key_contacts' => 1, 'mapdirections' => 1, 'notice_board' => 1, 'tourist_info' => 1));
     $tutorialModel->save();
     $newUser->setAttribute('status', 1);
     $newUser->setAttribute('tutorial_id', $tutorialModel->id);
     $newUser->save();
     return $newUser;
 }
コード例 #9
0
ファイル: common.php プロジェクト: kenicenoel/PackageHero
function generateSecurePassword($length)
{
    $ascii = PasswordGenerator::getASCIIPassword($length);
    return $ascii;
}
コード例 #10
0
function AjaxData($param)
{
    $password = new PasswordGenerator();
    return $password->getAjaxData($param);
}
コード例 #11
0
ファイル: index.php プロジェクト: sietekk/cscie15.project2
<?php

require './resources/passgen.php';
define('__apiURL__', 'http://randomword.setgetgo.com/get.php');
$testAPI = function ($apiURL) {
    $api = new SimpleHttpGetRequest();
    $api->setURL($apiURL);
    return $api->get() && $api->getStatus() === 200;
};
$passGen;
$passWord;
$showApiError;
if ($testAPI(__apiURL__)) {
    $showApiError = false;
    $passGen = new PasswordGenerator($_GET);
    $passGen->setWordApiURL(__apiURL__);
    $passWord = $passGen->generate();
} else {
    $showApiError = true;
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Project 2</title>
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
コード例 #12
0
ファイル: generate.php プロジェクト: spullen/cscie15-project2
<?php

require 'password_generator.php';
$json = file_get_contents('php://input');
$options = json_decode($json, true);
$pg = new PasswordGenerator($options);
header('Content-Type: application/json');
if ($pg->isValid()) {
    http_response_code();
    echo json_encode($pg->generate());
} else {
    http_response_code(422);
    echo json_encode($pg->errors);
}
コード例 #13
0
function PasswordGenerator()
{
    $password = new PasswordGenerator();
    return $password->viewHTML();
}
コード例 #14
0
<?php

/**
 * Plugin Password Generator
 *
 * *Description* Erzeugen von sicheren Passwörtern
 *
 * @author Alexander Weigelt <*****@*****.**>
 * @link http://alexander-weigelt.de
 * @version PLugin PasswordGenerator 1.0.0
 * @license http://creativecommons.org/licenses/by-nc-nd/4.0/legalcode CC BY-NC-ND 4.0
 */
if (defined('DIR_PROTECTION') and DIR_PROTECTION) {
    #Includes
    include_once dirname(__FILE__) . '/classes/PasswordGenerator.php';
    #Function
    $password = new PasswordGenerator();
    ?>

<p>Um deine Installation von Surftime CMS so sicher wie möglich gegen Angriffe von außen zu machen, empfiehlt es sich ein sicheres Passwort zu verwenden. Wenn Du spontan keine Ideen hast, kannst du dieses Tool zum Erzeugen eines neuen Passwort nutzen. Nach dem Generieren kopiere es einfach, und nutze es z.B. zum Anlegen eines neuen Benutzer.</p>
<?php 
    echo $password->viewHTML();
    ?>
<p><strong>Hinweis:</strong> Du kannst nur Passwörter generieren die aus mindestens 5 Zeichen bestehen.</p>

<?php 
}
コード例 #15
0
ファイル: test.php プロジェクト: glensc/php-passgen
    $hex_chars = array_merge($hex_chars, str_split($hex));
    $custom_chars = array_merge($custom_chars, str_split($custom));
}
$ascii_chars = array_unique($ascii_chars);
$alpha_chars = array_unique($alpha_chars);
$hex_chars = array_unique($hex_chars);
$custom_chars = array_unique($custom_chars);
if (count($ascii_chars) !== 94) {
    failTest("Not all ASCII chars are included.");
}
if (count($alpha_chars) !== 62) {
    failTest("Not all AlphaNumeric chars are included.");
}
if (count($hex_chars) !== 16) {
    failTest("Not all Hex chars are included.");
}
if (count($custom_chars) !== 2) {
    failTest("Not all Custom chars are included.");
}
if (PasswordGenerator::getCustomPassword("abc", 64) !== false) {
    failTest("Improper usage does not return false.");
}
for ($i = 0; $i < 1000; $i++) {
    $ints = PasswordGenerator::getRandomInts($i);
    $count = count($ints);
    if ($count != $i) {
        failTest("{$i} random ints is {$count} and not {$i}");
    }
}
echo "ALL TESTS PASS!\n";
exit(0);
コード例 #16
0
<?php

require_once 'word_list.php';
require_once 'password_generator.php';
$password_generator = new PasswordGenerator($word_list);
$errors = '';
foreach ($_POST as $key => $value) {
    try {
        $password_generator->{$key} = $value;
    } catch (Exception $e) {
        $errors .= $e->getMessage();
    }
}
$password_generator->generate_password();
コード例 #17
0
ファイル: generator.php プロジェクト: j-lee/readable-passgen
 *      http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 **************************************************************************************************/
require 'class.readable-passgen.php';
function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
// create a new PasswordGenerator class
$pass = new PasswordGenerator();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Readable Password Generator</title>
<style>
body			{ font:11px Verdana; }
a,a:visited		{ color:#00f; text-decoration:none; }
#wrapper		{ margin:10px; }
input,submit	{ font:11px Verdana; }
.success		{ color:#060; }
.failed			{ color:#f00; }
.lite			{ color:#999; }
.dirty			{ color:#00f; cursor:pointer; }
コード例 #18
0
 public function generatePassword($password = '')
 {
     if (!$this->id) {
         return "Non è stato possibile trovare l'id dello studente, contattare il fornitore!";
     }
     $tabella = "password";
     //Controllo se esiste già una password per l'utente
     $sql = "SELECT * FROM {$tabella} WHERE id_studente ='{$this->id}'";
     $auth = $this->connector->query($sql);
     if (mysql_num_rows($auth) > 0) {
         $res = $this->connector->getObjectResult($auth);
     }
     $pwdGen = new PasswordGenerator();
     if ($password == "") {
         $password = $pwdGen->createPassword();
     } else {
         $pwd = trim(filter_var($password, FILTER_SANITIZE_STRING));
     }
     if ($res) {
         $valori = array(sha1($password));
         $campi = array("password");
         $campi_com = array("id_studente");
         $valori_com = array($this->id);
         $auth = $this->connector->update($tabella, $campi, $valori, $campi_com, $valori_com);
         if (!$pwdGen->sendPassword($password, $this)) {
             return "Errore durante l'invio della password";
         }
     } else {
         $valori = array($this->id, sha1($password));
         $campi = array("id_studente", "password");
         $auth = $this->connector->insert($tabella, $campi, $valori);
     }
     if (mysql_errno() > 0) {
         return "Errore interno numero: " . mysql_errno() . " " . mysql_error();
     }
 }
コード例 #19
0
ファイル: index.php プロジェクト: spullen/cscie15-project2
    }
}
function displayChecked($cond)
{
    if ($cond) {
        echo 'checked="checked"';
    }
}
function displaySelected($val1, $val2)
{
    if ($val1 === $val2) {
        echo 'selected="selected"';
    }
}
$password = '';
$pg = new PasswordGenerator($_POST);
if ($pg->isValid()) {
    $password = $pg->generate();
}
?>
<div class="container">
  <div class="row">
    <div class="center">
      <h1>Password Generator</h1>
    </div>
    <hr>
  </div>
  <div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
      <div class="center">
        <h2 id="result"><?php 
コード例 #20
0
 public function actionSaveMember()
 {
     if (!Yii::app()->request->isPostRequest) {
         echo json_encode(array('status' => 0, 'message' => 'Only Post request are allowed.'));
         die;
     }
     if (Yii::app()->user->isGuest) {
         echo json_encode(array('status' => 0, 'message' => 'Only authorize user can allow this.'));
         die;
     }
     $member = new Member();
     $member->setAttributes($_POST);
     $member->validate();
     if (!UserAccessTable::checkUser2PropertyAccess(Yii::app()->user->getState('id'), $member->propertyId, UserAccessTable::FULL_ACCESS)) {
         echo json_encode(array('status' => 0, 'message' => 'You can not do this action.'));
         die;
     }
     $errors = $member->getErrors();
     if (count($errors) > 0) {
         echo json_encode(array('status' => 0, 'errors' => $errors));
         die;
     }
     //get property
     $property = Properties::model()->findByPk($member->propertyId);
     //check new user in database
     $user = User::model()->findByAttributes(array('email' => $member->email));
     if ($user != null) {
         //system already contains user with some email
         $eu2p = User2property::model()->with('user')->findByAttributes(array('userId' => $user->getAttribute('id'), 'propertyId' => $member->propertyId));
         if ($eu2p != null) {
             echo json_encode(array('status' => 0, 'message' => 'User already exist.'));
             die;
         }
         $u2p = new User2property();
         $u2p->setAttribute('userId', $user->getAttribute('id'));
         $u2p->setAttribute('bookingName', $member->bookname);
         $u2p->setAttributes($member->attributes);
         $u2p->save();
         $this->layout = "emailmaster";
         $emailBody = $this->render('../emails/emailInviteMember', array('userFullName' => $user->getAttribute('firstname') . ' ' . $user->getAttribute('lastname'), 'senderFullName' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'access' => UserAccessTable::accessLevelToString($member->access)), true);
         MailHelper::send($emailBody, "SharedKey.com - New Property Added to Your Account", array($user->getAttribute('email')));
         $temp = User2property::model()->with('user')->findByPk($u2p->getAttribute('id'));
         echo json_encode(array('status' => 1, 'member' => $this->createViewItem($temp)));
         die;
     }
     $newUser = new User();
     $newUser->setAttributes($member->attributes);
     $password = PasswordGenerator::generatePassword();
     $newUser->setAttribute('password', $password);
     $newUser->setAttribute('property_id', $member->propertyId);
     $tutorialModel = new TutorialModel();
     $tutorialModel->setAttributes(array('gallery' => 1, 'guest_book' => 1, 'house_rules' => 1, 'key_contacts' => 1, 'mapdirections' => 1, 'notice_board' => 1, 'tourist_info' => 1));
     $tutorialModel->save();
     $newUser->setAttribute('tutorial_id', $tutorialModel->id);
     $newUser->setAttribute('status', 1);
     $newUser->setAttribute('createdDate', new CDbExpression('NOW()'));
     $newUser->save();
     $u2p = new User2property();
     $u2p->setAttribute('userId', $newUser->getAttribute('id'));
     $u2p->setAttribute('bookingName', $member->bookname);
     $u2p->setAttributes($member->attributes);
     $u2p->save();
     $this->layout = "emailmaster";
     $emailBody = $this->render('../emails/emailInviteNewMember', array('userFullName' => $newUser->getAttribute('firstname') . ' ' . $newUser->getAttribute('lastname'), 'senderFullName' => Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname'), 'propertyName' => $property->getAttribute('property_name'), 'email' => $newUser->getAttribute('email'), 'access' => UserAccessTable::accessLevelToString($member->access), 'password' => $password), true);
     MailHelper::send($emailBody, "Sharedkey.com - Invitation to " . $property->getAttribute('property_name'), array($newUser->getAttribute('email')));
     $temp = User2property::model()->with('user')->findByPk($u2p->getAttribute('id'));
     echo json_encode(array('status' => 1, 'member' => $this->createViewItem($temp)));
     die;
 }