du1462 2016-06-28 15:38
浏览 51

我可以从序列号中提取客户名称吗?

I am trying to generate some sort of serial number using a customer name. This is for a PHP software I am developing. But I have never done trial systems and serial generation and stuff like this.

This is the code I use to generate the serial numbers:

<?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();
}
?>

How can I extract the customer name from the serial number?

  • 写回答

2条回答 默认 最新

  • drkjzk3359 2016-06-28 15:52
    关注

    If i understand your question correctly, you need to generate a serial number based on the customer name, and later be able to decode the serial number to get the customer name.

    You could convert the name to hex, but the string would in most cases get longer than the XXXXX-XXXXX-XXXXX-XXXXX-XXXXX format you're using now.

    Wouldn't it be better to just save the serial number in the database so you just have to check if the serial number is in the same row as the customer name?

    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错