Skip to content

Instantly share code, notes, and snippets.

@adeonir
Forked from erikfig/gist:d03e29c1ee60ffe1506a
Last active August 29, 2015 14:20
Show Gist options
  • Save adeonir/5297022602d682623dc0 to your computer and use it in GitHub Desktop.
Save adeonir/5297022602d682623dc0 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>CakePHP Gerador de Hash</title>
</head>
<body>
<h1>Gerador de Hash Para CakePHP</h1>
<p>Recarregue a p&aacute;gina para gerar novos hashs!</p>
<?php
function geraSenha($tamanho = 15, $minusculas = true, $maiusculas = true, $numeros = true, $simbolos = true)
{
$lmin = 'abcdefghijkmnopqrstuvwxyz';
$lmai = 'ABCDEFGHIJKLMNPQRSTUVWXYZ';
$num = '234567892345678923456789';
$simb = '!@#$%*-!@#$%*-!@#$%*-';
$retorno = '';
$caracteres = '';
if ($minusculas) $caracteres .= $lmin;
if ($maiusculas) $caracteres .= $lmai;
if ($numeros) $caracteres .= $num;
if ($simbolos) $caracteres .= $simb;
$len = strlen($caracteres);
for ($n = 1; $n <= $tamanho; $n++) {
$rand = mt_rand(1, $len);
$retorno .= $caracteres[$rand-1];
}
return $retorno;
}
echo '<h3>Security.salt</h3>';
echo '<p>'.geraSenha(41,true,true,true,false).'</p>';
echo '<h3>Security.cipherSeed</h3>';
echo '<p>'.geraSenha(29,false,false,true,false).'</p>';
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment