Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PHP to create TYPO3 salted password?

Tags:

php

typo3

I'm trying to create a custom registration component for TYPO3 on an external website where TYPO3 is not installed (i just use its database). Problem is i have no experience using TYPO3. I was wondering if anyone knew how to create the correct password encryption for TYPO3? The passwords looks like this :

$P$CeO/XYcbzRH9nLpCwKdp1HhsJGwJum0

I am looking for a php code to create that same encryption and check the password. I have the encrytion key from the install tools which (i believe) is used for the salting.

Or is there a possibility to save passwords as MD5 only? Not the best option but i could be the only one left.

I have found this url: http://srv123.typo3.org/TYPO3/Extensions/saltedpasswords/4.6/#compatibility-of-other-extensions-with-salted-user-password-hashes

But i have no clue how to implement that in my own script.

like image 861
Switching Brains Avatar asked Jul 25 '12 09:07

Switching Brains


2 Answers

Works on typo3 6.X:

    $password = 'XXX'; // plain-text password
    $saltedPassword = '';

    if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('saltedpasswords')) {
        if (\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) {
            $objSalt = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(NULL);
            if (is_object($objSalt)) {
                $saltedPassword = $objSalt->getHashedPassword($password);
            }
        }
    }
like image 162
Nicolas F. Avatar answered Sep 30 '22 22:09

Nicolas F.


Have a look at the developer guide:

1.5.1 Creating a new salted user password hash from a given plain-text password

You have to use it in the typo3-Frontend:

$password = 'XXX'; // plain-text password
$saltedPassword = '';

if (t3lib_extMgm::isLoaded('saltedpasswords')) {
  if (tx_saltedpasswords_div::isUsageEnabled('FE')) {
    $objSalt = tx_saltedpasswords_salts_factory::getSaltingInstance(NULL);
    if (is_object($objSalt)) {
      $saltedPassword = $objSalt->getHashedPassword($password);
    }
  }
}

But, you should never try to generate salted password outside of typo3 because the encryption depends on your typo3 settings.

like image 36
Besnik Avatar answered Sep 30 '22 22:09

Besnik