vendor/symfony/security-core/Encoder/Pbkdf2PasswordEncoder.php line 16

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <[email protected]>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Core\Encoder;
  11. use Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher;
  12. trigger_deprecation('symfony/security-core', '5.3', 'The "%s" class is deprecated, use "%s" instead.', Pbkdf2PasswordEncoder::class, Pbkdf2PasswordHasher::class);
  13. /**
  14. * Pbkdf2PasswordEncoder uses the PBKDF2 (Password-Based Key Derivation Function 2).
  15. *
  16. * Providing a high level of Cryptographic security,
  17. * PBKDF2 is recommended by the National Institute of Standards and Technology (NIST).
  18. *
  19. * But also warrants a warning, using PBKDF2 (with a high number of iterations) slows down the process.
  20. * PBKDF2 should be used with caution and care.
  21. *
  22. * @author Sebastiaan Stok <[email protected]>
  23. * @author Andrew Johnson
  24. * @author Fabien Potencier <[email protected]>
  25. *
  26. * @deprecated since Symfony 5.3, use {@link Pbkdf2PasswordHasher} instead
  27. */
  28. class Pbkdf2PasswordEncoder extends BasePasswordEncoder
  29. {
  30. use LegacyEncoderTrait;
  31. /**
  32. * @param string $algorithm The digest algorithm to use
  33. * @param bool $encodeHashAsBase64 Whether to base64 encode the password hash
  34. * @param int $iterations The number of iterations to use to stretch the password hash
  35. * @param int $length Length of derived key to create
  36. */
  37. public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase64 = true, int $iterations = 1000, int $length = 40)
  38. {
  39. $this->hasher = new Pbkdf2PasswordHasher($algorithm, $encodeHashAsBase64, $iterations, $length);
  40. }
  41. }