• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/rsabcmath.php
  • Класс: CRsaBcmathProvider
  • Вызов: CRsaBcmathProvider::miller
static function miller($in, $b)
{
	if(!bccomp($in, '1'))
		return false;

	$t = bcsub($in, '1');

	$nulcnt = 0;
	while(!bccomp(bcmod($t, '2'), '0')) 
	{
		$nulcnt++;
		$t = bcdiv($t, '2');
	}

	$t = self::powmod($b, $t, $in);
	if(!bccomp($t, '1')) 
		return true;

	while($nulcnt--) 
	{
		if(!bccomp(bcadd($t, '1'), $in)) 
			return true;

		$t = self::powmod($t, '2', $in);
	}
	return false;
}