1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
weakpassword.php
См. документацию.
1
<?php
2
9
10
namespace
Bitrix\Main\Authentication\Policy;
11
12
use Bitrix\Main\IO;
13
14
class
WeakPassword
15
{
16
public
const
MIN_PASSWORD_LENGTH
= 6;
17
25
public
static
function
createIndex
(
string
$dataFile,
string
$path
): bool
26
{
27
$file =
new
IO\File
($dataFile);
28
29
$passwords = $file->getContents();
30
31
$passwords = str_replace([
"\r\n"
,
"\r"
],
"\n"
, $passwords);
32
$passwords = explode(
"\n"
, $passwords);
33
34
$hashedPasswords = [];
35
foreach
($passwords as
$password
)
36
{
37
if
(strlen(
$password
) >= self::MIN_PASSWORD_LENGTH)
38
{
39
$hash
= md5(
$password
);
40
$name
=
$hash
[0] .
$hash
[1];
// 256 possible keys
41
$hashedPasswords[
$name
][] = (string)
$password
;
42
}
43
}
44
unset($passwords);
45
46
foreach
($hashedPasswords as
$name
=> $value)
47
{
48
// we need the first and the last \n as a search pattern separator
49
$content
=
"\n"
. implode(
"\n"
, $value) .
"\n"
;
50
51
$indexFile =
new
IO\File
(
$path
.
'/'
.
$name
.
'.txt'
);
52
53
if
($indexFile->putContents(
$content
) ===
false
)
54
{
55
return
false
;
56
}
57
}
58
59
return
true
;
60
}
61
69
public
static
function
exists
(
string
$password
,
string
$path
): bool
70
{
71
$hash
= md5(
$password
);
72
$name
=
$hash
[0] .
$hash
[1];
73
74
$indexFile =
new
IO\File
(
$path
.
'/'
.
$name
.
'.txt'
);
75
76
if
(!$indexFile->isExists())
77
{
78
return
false
;
79
}
80
81
$passwords = $indexFile->getContents();
82
83
return
(str_contains($passwords,
"\n"
.
$password
.
"\n"
));
84
}
85
}
$path
$path
Определения
access_edit.php:21
$hash
$hash
Определения
ajax_redirector.php:8
Bitrix\Main\Authentication\Policy\WeakPassword
Определения
weakpassword.php:15
Bitrix\Main\Authentication\Policy\WeakPassword\MIN_PASSWORD_LENGTH
const MIN_PASSWORD_LENGTH
Определения
weakpassword.php:16
Bitrix\Main\Authentication\Policy\WeakPassword\exists
static exists(string $password, string $path)
Определения
weakpassword.php:69
Bitrix\Main\Authentication\Policy\WeakPassword\createIndex
static createIndex(string $dataFile, string $path)
Определения
weakpassword.php:25
$content
$content
Определения
commerceml.php:144
$name
$name
Определения
menu_edit.php:35
Bitrix\Main\File
Определения
Image.php:9
Bitrix\Main\$password
$password
Определения
mysql_to_pgsql.php:34
bitrix
modules
main
lib
authentication
policy
weakpassword.php
Создано системой
1.14.0