Issue Bug Closed

#29220createEncryptionKey always returns key with 96 characters

Adrian Rochau 08/24/11, 14:04 updated 10/02/18, 12:19

Description

In file introductionpackage-4.5.4\typo3\sysext\install\mod\class.tx_install.php in function createEncryptionKey a parameter $keyLength can be set but is ignored in the end.

Since bin2hex returns two characters for each byte the following version should be sufficient.

Instead of:

public function createEncryptionKey($keyLength = 96) {
    $bytes = t3lib_div::generateRandomBytes($keyLength);
    return substr(bin2hex($bytes), -96);
}

Use:

public function createEncryptionKey($keyLength = 96) {
    $bytes = t3lib_div::generateRandomBytes(ceil($keyLength/2));
    return substr(bin2hex($bytes), $keyLength);
}

Reviews 3