• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/crypt.php
  • Класс: CCryptblowfish
  • Вызов: CCryptblowfish::__BlowfishCrypt
function __BlowfishCrypt(&$Xl, &$Xr)
{
	// Blowfish is a Feistel network consisting of 16 rounds (see Figure 1). 
	// The input is a 64-bit data element, x

	// Divide x into two 32-bit halves: xL, xR
	// For i = 1 to 16:
	//		xL = xL XOR Pi
	//		xR = F(xL) XOR xR
	//		Swap xL and xR
	// end For
	// Swap xL and xR (Undo the last swap)
	// xR = xR XOR P17
	// xL = xL XOR P18
	// Recombine xL and xR

	for ($i = 0; $i < 16; $i++)
	{
		$Xl = $Xl ^ $this->arSubkeys["P"][$i];
		$Xr = $this->__F($Xl) ^ $Xr;

		$tmp = $Xl;
		$Xl = $Xr;
		$Xr = $tmp;
	}

	$tmp = $Xl;
	$Xl  = $Xr;
	$Xr  = $tmp;

	$Xr  = $Xr ^ $this->arSubkeys["P"][16];
	$Xl  = $Xl ^ $this->arSubkeys["P"][17];
}