Skip to content

Instantly share code, notes, and snippets.

@rodrigojusto
Created July 5, 2018 22:28
Show Gist options
  • Save rodrigojusto/809a258b394901e15c93f078c5cc8001 to your computer and use it in GitHub Desktop.
Save rodrigojusto/809a258b394901e15c93f078c5cc8001 to your computer and use it in GitHub Desktop.
<?php
function randomPassword(){
$str = "abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPKRSTUWVXYZ0123456789!@#$&*-+=";
$caracter = str_split($str);
$senha = '';
for ($i = 0; $i < 8; $i++){ //senha de 8 caracteres
$indice = rand(0, strlen($str)-1);
$senha .= $caracter[$indice];
}
Return $senha;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment