<commit_before><?php

namespace vxPHP\Util;

/**
 * Create passwords
 * 
 * @author <NAME>,  <NAME>
 * @author <NAME>
 * 
 * @version 1.0.3 2008-08-17
 */

class PasswordGenerator {
	/**
	* Create a single password.
	*
	* @param  integer Length of the password.
	* @param  string  Type of password (pronounceable, unpronounceable)
	* @param  string  Character which could be use in the
	*                 unpronounceable password ex : '<PASSWORD>'
	*                 or numeric or alphanumeric.
	* @return string  Returns the generated password.
	*/

	public function create($length = 10, $type = 'pronounceable', $chars = '') {
		mt_srand();

		switch ($type) {
			case 'unpronounceable' :
				return self::createUnpronounceable($length, $chars);
			case 'pronounceable' :
			default :
				return self::createPronounceable($length);
		}
	}

	/**
	* Create multiple, different passwords
	*
	* Method to create a list of different passwords which are
	* all different.
	*
	* @param  integer Number of different password
	* @param  integer Length of the password
	* @param  string  Type of password (pronounceable, unpronounceable)
	* @param  string  Character which could be use in the
	*                 unpronounceable password ex : 'A,B,C,D,<PASSWORD>,G'
	*                 or numeric or alphanumeric.
	* @return array   Array containing the passwords
	*/
	public function createMultiple($number, $length = 10, $type = 'pronounceable', $chars = '') {
		$passwords = array();

		while ($number > 0) {
			while(true) {
				$password = self::create($length, $type, $chars);
				if (!in_array($password, $passwords)) {
					$passwords[] = $password;
					break;
				}
			}
			$number--;
		}
		return $passwords;
	}

	/**
	* Create password from login
	*
	* Method to create password from login
	*
	* @param  string  Login
	* @param  string  Type
	* @param  integer Key
	* @return string
	*/
	public function createFromLogin($login, $type, $key = 0) {
		switch($type) {
			case 'reverse':			return strrev($login);
			case 'shuffle':			return self::shuffle($login);
			case 'xor':				return self::eXor($login, $key);
			case 'rot13':			return str_rot13($login);
			case 'rotx':			return self::rotx($login, $key);
			case 'rotx++':			return self::rotxpp($login, $key);
			case 'rotx--':			return self::rotxmm($login, $key);
			case 'ascii_rotx':		return self::asciiRotx($login, $key);
			case 'ascii_rotx++':	return self::asciiRotxpp($login, $key);
			case 'ascii_rotx--':	return self::asciiRotxmm($login, $key);
		}
	}

	/**
	* Create multiple, different passwords from an array of login
	*
	* Method to create a list of different password from login
	*
	* @param  array   Login
	* @param  string  Type
	* @param  integer Key
	* @return array   Array containing the passwords
	*/
	public function createMultipleFromLogin($login, $type, $key = 0) {
		$passwords = array();
		$number    = count($login);
		$save      = $number;

		while ($number > 0) {
			while (true) {
				$password = self::createFromLogin($login[$save - $number], $type, $key);
				if (!in_array($password, $passwords)) {
					$passwords[] = $password;
					break;
				}
			}
			$number--;
		}
		return $passwords;
	}

	private static function eXor($login, $key) {
		$tmp = '';

		for ($i = 0; $i < strlen($login); $i++) {<commit_msg>Bugfix: Static methods were not declared as static<commit_after><?php

namespace vxPHP\Util;

/**
 * Create passwords
 * 
 * @author <NAME>,  <NAME>
 * @author <NAME>
 * 
 * @version 1.0.4 2015-12-09
 */

class PasswordGenerator {
	/**
	* Create a single password.
	*
	* @param  integer Length of the password.
	* @param  string  Type of password (pronounceable, unpronounceable)
	* @param  string  Character which could be use in the
	*                 unpronounceable password ex : '<PASSWORD>'
	*                 or numeric or alphanumeric.
	* @return string  Returns the generated password.
	*/

	public static function create($length = 10, $type = 'pronounceable', $chars = '') {
		mt_srand();

		switch ($type) {
			case 'unpronounceable' :
				return self::createUnpronounceable($length, $chars);
			case 'pronounceable' :
			default :
				return self::createPronounceable($length);
		}
	}

	/**
	* Create multiple, different passwords
	*
	* Method to create a list of different passwords which are
	* all different.
	*
	* @param  integer Number of different password
	* @param  integer Length of the password
	* @param  string  Type of password (pronounceable, unpronounceable)
	* @param  string  Character which could be use in the
	*                 unpronounceable password ex : '<PASSWORD>,F,G'
	*                 or numeric or alphanumeric.
	* @return array   Array containing the passwords
	*/
	public static function createMultiple($number, $length = 10, $type = 'pronounceable', $chars = '') {
		$passwords = array();

		while ($number > 0) {
			while(true) {
				$password = self::create($length, $type, $chars);
				if (!in_array($password, $passwords)) {
					$passwords[] = $password;
					break;
				}
			}
			$number--;
		}
		return $passwords;
	}

	/**
	* Create password from login
	*
	* Method to create password from login
	*
	* @param  string  Login
	* @param  string  Type
	* @param  integer Key
	* @return string
	*/
	public static function createFromLogin($login, $type, $key = 0) {
		switch($type) {
			case 'reverse':			return strrev($login);
			case 'shuffle':			return self::shuffle($login);
			case 'xor':				return self::eXor($login, $key);
			case 'rot13':			return str_rot13($login);
			case 'rotx':			return self::rotx($login, $key);
			case 'rotx++':			return self::rotxpp($login, $key);
			case 'rotx--':			return self::rotxmm($login, $key);
			case 'ascii_rotx':		return self::asciiRotx($login, $key);
			case 'ascii_rotx++':	return self::asciiRotxpp($login, $key);
			case 'ascii_rotx--':	return self::asciiRotxmm($login, $key);
		}
	}

	/**
	* Create multiple, different passwords from an array of login
	*
	* Method to create a list of different password from login
	*
	* @param  array   Login
	* @param  string  Type
	* @param  integer Key
	* @return array   Array containing the passwords
	*/
	public static function createMultipleFromLogin($login, $type, $key = 0) {
		$passwords = array();
		$number    = count($login);
		$save      = $number;

		while ($number > 0) {
			while (true) {
				$password = self::createFromLogin($login[$save - $number], $type, $key);
				if (!in_array($password, $passwords)) {
					$passwords[] = $password;
					break;
				}
			}
			$number--;
		}
		return $passwords;
	}

	private static function eXor($login, $key) {
		$tmp = '';

		for ($i = 0; $i < strlen($login); $i++) {
{'fraction_non_alphanumeric': 0.14154770848985726, 'fraction_numerical': 0.007212622088655147, 'mean_word_length': 3.217997465145754, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4415906', 'n_tokens_mistral': 2493, 'n_tokens_neox': 2196, 'n_words': 635}