I'm using Random class to generate a password for a new user in my custom module.
I added the namespace in my module controller: use \Drupal\Component\Utility\Random;
And I am using it like this:
$user = User::create();
$user->setPassword(Random::string());
Problem is this function seems to be deprecated, however I found it in the Drupal API documentation.
Here is the error I get:
Deprecated function: Non-static method Drupal\Component\Utility\Random::string()
Did I use it wrong or do you know a better way to generate a random string ?
Drupal version: 8.4