New in Symfony 2.2: Security Utilities
As of Symfony 2.2, we have refactored some security utilities so that you can
use them in your own code. These utilities are available in the
Generating a secure Random Number¶
If you need to generate a secure random number, you'd better rely on a strong implementation. Symfony provides one:
1 2 3 4
use Symfony\Component\Security\Core\Util\SecureRandom; $generator = new SecureRandom(); $random = $generator->nextBytes(10);
nextBytes() methods returns a random string composed of the number of
characters passed as an argument (
10 in the above example).
Timing attacks are not that well-known, but still, Symfony has protection for them. In Symfony 2.0 and 2.1, this protection was applied to password comparisons done in the Security bundle, but as of Symfony 2.2, it is also available to the developer:
1 2 3 4
use Symfony\Component\Security\Core\Util\StringUtils; // is password1 equals to password2? $bool = StringUtils::equals($password1, $password2);
Want to learn more? Have a look at the dedicated documentation.
New in Symfony 2.2: Security Utilities symfony.com/blog/new-in-symfony-2-2-security-utilitiesTweet this
Become a certified developer! Exams are online and available in all countries.Register Now
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.