mardi 3 avril 2018

PHP 7 OAuthProvider VS random_bytes token generation

My goal is simply to generate a temporary token that will be used in URLs for user identification, should I use OAuthProvider::generateToken or random_bytes?

From these answers :

Generate a single use token in PHP: random_bytes or openssl_random_pseudo_bytes?

and

best practice to generate random token for forgot password

It seems that random_bytes is a more recently updated option for PHP 7 when compared to openssl_random_pseudo_bytes. Is it the same when compared to OAuthProvider::generateToken?

Examples:

$rb_token = bin2hex(random_bytes($length));
$oa_token = bin2hex((new OAuthProvider())->generateToken($length, TRUE));
// TRUE = strong "/dev/random will be used for entropy"




Aucun commentaire:

Enregistrer un commentaire