$myString = 'Hello World'; $shortHash = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($myString); echo $shortHash; // outputs "5d41402a"
$existingHash = '5d41402a'; $newString = 'Hello World'; $newHash = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($newString); if ($existingHash === $newHash) { echo 'Hashes match'; } else { echo 'Hashes do not match'; }In both examples, we are calling the shortMD5() method of the GeneralUtility class and passing a string as a parameter. We then use the resulting hash in different ways - either by outputting it or comparing it to an existing hash. The package library for this code is TYPO3\CMS\Core.