Пример #1
0
 public function generateRandomPassword($length = 10, $string = '', $type = 'pronounceable')
 {
     if (!$type and $string) {
         $type = 'pronounceable';
     } elseif (!$type) {
         $type = 'unpronounceable';
     }
     require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'res/Password.php';
     $suite = new Text_Password();
     switch ($type) {
         case 'pronounceable':
             $password = $suite->create($length, 'pronounceable', $string);
             $password .= rand(10, 99);
             break;
         case 'unpronounceable':
             $password = $suite->create($length, 'unpronounceable', $string . '0123456789!@#$%^&*(');
             break;
         case 'shuffle':
         default:
             $password = $suite->createFromLogin($string, 'shuffle');
             $password .= rand(10, 99);
             break;
     }
     return $password;
 }
Пример #2
0
 /**
  * Create multiple, different passwords from an array of login
  *
  * Method to create a list of different password from login
  *
  * @access public
  * @param  array   Login
  * @param  string  Type
  * @param  integer Key
  * @return array   Array containing the passwords
  */
 function createMultipleFromLogin($login, $type, $key = 0)
 {
     $passwords = array();
     $number = count($login);
     $save = $number;
     while ($number > 0) {
         while (true) {
             $password = Text_Password::createFromLogin($login[$save - $number], $type, $key);
             if (!in_array($password, $passwords)) {
                 $passwords[] = $password;
                 break;
             }
         }
         $number--;
     }
     return $passwords;
 }
 public function testCreateFromLoginASCIIRotXminusminus()
 {
     $this->assertEquals("uyn", Text_Password::createFromLogin("joe", "ascii_rotx--", 11));
 }