【发布时间】:2016-10-31 00:56:57
【问题描述】:
我正在尝试使用客户名称生成某种序列号。 这是针对我正在开发的 PHP 软件的。但我从来没有做过试验系统和串行生成之类的东西。
这是我用来生成序列号的代码:
<?php
// URL is = http://teionsoft.com/classified/keygen.php?token=
$token = @$_POST['token'];
if(empty($token))
{
echo '
<p>Token can not be blank or zero.</p>
<p>
<form action="keygen.php" method="post">
<input type="text" name="token" id="token" placeholder="Type in your full name" /><br /><br />
<input type="submit" name="submit" value="Get serial!" />
</form>
</p>';
exit;
}
function serialKey() {
// Create a token
// GUID is 128-bit hex
$hash = strtoupper(md5($token));
// Create formatted GUID
$guid = '';
// GUID format is XXXXX-XXXXX-XXXXX-XXXXX-XXXXX for readability
$guid .= substr($hash, 0, 5) .
'-' .
substr($hash, 8, 5) .
'-' .
substr($hash, 12, 5) .
'-' .
substr($hash, 16, 5) .
'-' .
substr($hash, 20, 5);
// temporary code to test base64 codeing / decoding ;
$string = $guid;
$encoded = base64_encode($string);
$decoded = base64_decode($encoded);
echo $encoded ."<br /><br />";
echo $decoded;
}
if(isset($_POST['submit']))
{
serialKey();
}
?>
如何从序列号中提取客户名称?
【问题讨论】:
-
使用 sha256 代替 md5
-
对于唯一 ID 阅读此php.net/manual/es/function.uniqid.php
-
您在那里提到了 GUID,但您没有生成 GUID。检查en.wikipedia.org/wiki/Globally_unique_identifier#Algorithm
标签: php numbers unique generator