gebruiksvriendelijke-password
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Generates a password based on 600 words of lorum lipsum
* and a given username
*
* @author Jason de Ridder
* @version 1.0
* @depance func URLString
* @param string $username
* @param [int $length]
* @return string password
*/
function generateUserFriendlyPass($username, $length = 8) {
$username = str_replace('-', '', URLstring($username));
$omvormer = array(
'a' => '4',
'i' => '1',
'e' => '3',
);
$woorden = array('Lorem','ipsum','dolor','sit','amet','consectetuer','adipiscing','elit','Cras','sit','amet','nulla','eu','eros','convallis','tempor','Vivamus','tincidunt','Integer','scelerisque','elementum','tortor','Morbi','egestas','orci','quis','arcu','Nulla','varius','Nullam','pulvinar','sem','sed','diam','Lorem','ipsum','dolor','sit','amet','consectetuer','adipiscing','elit','Vivamus','eu','ipsum','eget','ligula','congue','interdum','Nullam','quam','magna','aliquam','et','posuere','non','vulputate','cursus','turpis','Mauris','erat','purus','facilisis','vitae','tristique','in','posuere','sit','amet','massa','Phasellus','convallis','libero','imperdiet','molestie','fringilla','massa','arcu','sodales','ipsum','ut','luctus','ante','lorem','non','eros','Fusce','elit','pede','placerat','aliquet','volutpat','ac','euismod','vitae','purus','Nunc','non','nunc','eu');
$woorden = array_unique($woorden);
$password = '';
$loops = rand($length - 2, $length) / 2;
for($i = 0; $i < $loops; $i++) {
$woord = $woorden[rand(0, count($woorden))];
$username_sub = substr($username, $i * 2, 1);
if(isset($omvormer[$username_sub])) {
$password .= $omvormer[$username_sub];
}
else {
$password .= $username_sub;
}
$password .= strtolower(substr($woord, rand(0, strlen($woord) - 1), 1));
}
if(($length - strlen($password)) > 0) {
for($i = 0; $i < ($length - strlen($password)); $i++) {
switch(rand(0, 3)) {
case 0:
$password .= strtolower(substr($woord, rand(0, strlen($woord) - 1), 1));
break;
case 1:
$password .= '!';
break;
case 2:
$password .= '@';
break;
case 3:
$password .= '#';
break;
}
}
}
return $password;
}
/**
* Transforms almost all special characters to their a-z counterparts and transforms spaces into dashes
*
* @param string $strInput
* @return string
*/
function URLstring($inputString) {
$inputString = trim($inputString);
$inputString = strtolower(utf8_decode($inputString));
$outputString = preg_replace('/[\xC0-\xC5\xE0-\xE5]/', 'a', $inputString);
$outputString = preg_replace('/[\xE6]/', 'ae', $outputString);
$outputString = preg_replace('/[\xC7\xE7]/', 'c',$outputString);
$outputString = preg_replace('/[\x82\xC8-\xCB\xE8-\xEB]/', 'e',$outputString);
$outputString = preg_replace('/[\xCC-\xCF\xEC-\xEF]/', 'i',$outputString);
$outputString = preg_replace('/[\xF1\xD1]/', 'n',$outputString);
$outputString = preg_replace('/[\xF2-\xF6\xF8\xD8\xD2-\xD6]/', 'o',$outputString);
$outputString = preg_replace('/[\x8A\x9A]/', 's',$outputString);
$outputString = preg_replace('/[\xD9\xDA\xDB\xDC\xF9-\xFC]/', 'u',$outputString);
$outputString = preg_replace('/[\xFD\xFF\x9F\xDD]/', 'y',$outputString);
$outputString = preg_replace('/[\x9E]/', 'z',$outputString);
$outputString = preg_replace('/[^[[:alnum:]\-\s]/', '',$outputString);
$outputString = preg_replace('/\s{1,}/', '-',$outputString);
return $outputString;
}
?>
/**
* Generates a password based on 600 words of lorum lipsum
* and a given username
*
* @author Jason de Ridder
* @version 1.0
* @depance func URLString
* @param string $username
* @param [int $length]
* @return string password
*/
function generateUserFriendlyPass($username, $length = 8) {
$username = str_replace('-', '', URLstring($username));
$omvormer = array(
'a' => '4',
'i' => '1',
'e' => '3',
);
$woorden = array('Lorem','ipsum','dolor','sit','amet','consectetuer','adipiscing','elit','Cras','sit','amet','nulla','eu','eros','convallis','tempor','Vivamus','tincidunt','Integer','scelerisque','elementum','tortor','Morbi','egestas','orci','quis','arcu','Nulla','varius','Nullam','pulvinar','sem','sed','diam','Lorem','ipsum','dolor','sit','amet','consectetuer','adipiscing','elit','Vivamus','eu','ipsum','eget','ligula','congue','interdum','Nullam','quam','magna','aliquam','et','posuere','non','vulputate','cursus','turpis','Mauris','erat','purus','facilisis','vitae','tristique','in','posuere','sit','amet','massa','Phasellus','convallis','libero','imperdiet','molestie','fringilla','massa','arcu','sodales','ipsum','ut','luctus','ante','lorem','non','eros','Fusce','elit','pede','placerat','aliquet','volutpat','ac','euismod','vitae','purus','Nunc','non','nunc','eu');
$woorden = array_unique($woorden);
$password = '';
$loops = rand($length - 2, $length) / 2;
for($i = 0; $i < $loops; $i++) {
$woord = $woorden[rand(0, count($woorden))];
$username_sub = substr($username, $i * 2, 1);
if(isset($omvormer[$username_sub])) {
$password .= $omvormer[$username_sub];
}
else {
$password .= $username_sub;
}
$password .= strtolower(substr($woord, rand(0, strlen($woord) - 1), 1));
}
if(($length - strlen($password)) > 0) {
for($i = 0; $i < ($length - strlen($password)); $i++) {
switch(rand(0, 3)) {
case 0:
$password .= strtolower(substr($woord, rand(0, strlen($woord) - 1), 1));
break;
case 1:
$password .= '!';
break;
case 2:
$password .= '@';
break;
case 3:
$password .= '#';
break;
}
}
}
return $password;
}
/**
* Transforms almost all special characters to their a-z counterparts and transforms spaces into dashes
*
* @param string $strInput
* @return string
*/
function URLstring($inputString) {
$inputString = trim($inputString);
$inputString = strtolower(utf8_decode($inputString));
$outputString = preg_replace('/[\xC0-\xC5\xE0-\xE5]/', 'a', $inputString);
$outputString = preg_replace('/[\xE6]/', 'ae', $outputString);
$outputString = preg_replace('/[\xC7\xE7]/', 'c',$outputString);
$outputString = preg_replace('/[\x82\xC8-\xCB\xE8-\xEB]/', 'e',$outputString);
$outputString = preg_replace('/[\xCC-\xCF\xEC-\xEF]/', 'i',$outputString);
$outputString = preg_replace('/[\xF1\xD1]/', 'n',$outputString);
$outputString = preg_replace('/[\xF2-\xF6\xF8\xD8\xD2-\xD6]/', 'o',$outputString);
$outputString = preg_replace('/[\x8A\x9A]/', 's',$outputString);
$outputString = preg_replace('/[\xD9\xDA\xDB\xDC\xF9-\xFC]/', 'u',$outputString);
$outputString = preg_replace('/[\xFD\xFF\x9F\xDD]/', 'y',$outputString);
$outputString = preg_replace('/[\x9E]/', 'z',$outputString);
$outputString = preg_replace('/[^[[:alnum:]\-\s]/', '',$outputString);
$outputString = preg_replace('/\s{1,}/', '-',$outputString);
return $outputString;
}
?>