Deprecation: #102762 - Deprecate GeneralUtility::hmac()¶
See forge#102762
Description¶
The method \TYPO3\CMS\Core\Utility\GeneralUtility::hmac()
has been deprecated in TYPO3 v13 and will be removed with v14 in
favor of Feature: #102761 - Introduce class to generate/validate HMAC hashes.
Impact¶
Usage of the method will raise a deprecation level log entry in TYPO3 v13 and a fatal error in TYPO3 v14.
Affected installations¶
All third-party extensions using \TYPO3\CMS\Core\Utility\GeneralUtility::hmac()
.
Migration¶
All usages of \TYPO3\CMS\Core\Utility\GeneralUtility::hmac()
must be migrated to use the hmac()
method in the class
\TYPO3\CMS\Core\Crypto\HashService
.
Before¶
//use TYPO3\CMS\Core\Utility\GeneralUtility;
$hmac = GeneralUtility::hmac('some-input', 'some-secret');
Copied!
After¶
//use TYPO3\CMS\Core\Crypto\HashService;
//use TYPO3\CMS\Core\Utility\GeneralUtility;
$hashService = GeneralUtility::makeInstance(HashService::class);
$hmac = $hashService->hmac('some-input', 'some-secret');
Copied!
namespace MyVendor\MyExt\Services;
use TYPO3\CMS\Core\Crypto\HashService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
final readonly class MyService
{
public function __construct(
private HashService $hashService,
) {}
public function someMethod(): void
{
$hmac = $this->hashService->hmac('some-input', 'some-secret');
}
}
Copied!
If possible, use dependency injection to inject HashService
into your class.