public generateRandomString ( integer $length, string $chars = '' ) : string | ||
$length | integer | Length of the generated string. |
$chars | string | A string containing a list of chars that will be uses for generating the random string. |
return | string | Random string with the given $length containing only the provided set of $chars. |
public function generateRandomString($length, $chars = '')
{
try {
return $this->driverInstance->generateRandomString($length, $chars);
} catch (\Exception $e) {
throw new CryptException($e->getMessage());
}
}
public function testGenerateRandomString() { $crypt = new Crypt(); $randomString = $crypt->generateRandomString(9, 'abc'); $this->assertInternalType('string', $randomString); }