• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/security/weakpassword.php
  • Класс: Bitrix\Main\Security\WeakPassword
  • Вызов: WeakPassword::createIndex
static function createIndex(string $dataFile, string $path): bool
{
	$file = new IO\File($dataFile);

	$passwords = $file->getContents();

	$passwords = str_replace(["\r\n", "\r"], "\n", $passwords);
	$passwords = explode("\n", $passwords);

	$hashedPasswords = [];
	foreach ($passwords as $password)
	{
		$hash = md5($password);
		$name = $hash[0] . $hash[1]; // 256 possible keys
		$hashedPasswords[$name][] = (string)$password;
	}
	unset($passwords);

	foreach ($hashedPasswords as $name => $value)
	{
		// we need the first and the last \n as a search pattern separator
		$content = "\n" . implode("\n", $value) . "\n";

		$indexFile = new IO\File($path . '/' . $name . 'txt');

		if ($indexFile->putContents($content) === false)
		{
			return false;
		}
	}

	return true;
}