我正在尝试使用客户名称生成某种序列号。 这是一个我正在开发的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阅读此http://php.net/manual/es/function.uniqid.php –
你提到GUID那里,但你没有生成一个GUID。查看https://en.wikipedia.org/wiki/Globally_unique_identifier#Algorithm – apokryfos