HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/public/snappymail/snappymail/v/2.38.2/app/libraries/snappymail/sasl/cram.php
<?php

namespace SnappyMail\SASL;

class Cram extends \SnappyMail\SASL
{

	function __construct(string $algo)
	{
		$algo = \strtolower($algo);
		if (!\in_array($algo, \hash_algos())) {
			throw new \Exception("Unsupported SASL CRAM algorithm: {$algo}");
		}
		$this->algo = $algo;
	}

	public function authenticate(string $authcid,
		#[\SensitiveParameter]
		string $passphrase,
		?string $challenge = null
	) : string
	{
		if (empty($challenge)) {
			$this->writeLogException(new \MailSo\Smtp\Exceptions\NegativeResponseException);
		}
		return $this->encode($authcid . ' ' . \hash_hmac($this->algo, $this->decode($challenge), $passphrase));
	}

	public static function isSupported(string $param) : bool
	{
		return \in_array(\strtolower($param), \hash_algos());
	}

}