DigitalProductId解密算法php调试版piddebug.php

php 复制代码
<?php
// 使用数组字面量
$digits = ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R',
        'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9'];
//foreach ($digits as $digit) {
//    echo $digit."<br>";
//}
 
$hexPid=array(0xc2,0x49,0x4b,0xcc,0x60,0x34,0x09,0xcd,0x96,0xf7,0xec,0x94,0x0e,0x97,0x02);
 
// $decodedChars= ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R',
//        'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9', '6', '7', '8', '9', '9'];
$decodedChars= array_fill(0, 29, "a"); // 创建一个包含三个 "fruit" 的数组
//print_r($decodedChars);        
//print_r($hexPid[0]);
//    echo "<br>";
//print_r($hexPid);
$decodeLength = 29; 
$decodeStringLength = 15;

  for ( $i = $decodeLength - 1;$i >= 0; $i--)
    {
        // Every sixth char is a separator.
        if (($i + 1) % 6 == 0)
        {
            $decodedChars[$i] = '-';
            echo "<br>"."<br>"."\$i=".$i."<br>"; 
            echo "\$ecodedChars[".$i."]=".$decodedChars[$i]."<br>";
        }
        else
        {
            // Do the actual decoding.
             $digitMapIndex = 0;
            echo "<br>"."<br>"."\$i=".$i."<br>";
            echo "<br>"."\$hexPid= ";
            for ( $k=0;$k <= $decodeStringLength - 1; $k++)
            {
                echo "[".$k."]=".str_pad(strtoupper(dechex($hexPid[$k])), 2, '0', STR_PAD_LEFT)." ";
                //print_r($hexPid[$k]);
            }
            //echo "\$hexPid=";
            //print_r($hexPid);
            echo "<br>";
            for ( $j = $decodeStringLength - 1; $j >= 0; $j--)
            {
                $byteValue = ($digitMapIndex << 8) | $hexPid[$j];
                echo "<br>"."--------"."\$j=".$j."<br>"; 
                echo  "\$byteValue="."0x".$digitMapIndex.str_pad(strtoupper(dechex($hexPid[$j])),2, '0', STR_PAD_LEFT)."=".$byteValue."<br>";
                $hexPid[$j] = floor($byteValue / 24);
                
                $digitMapIndex = $byteValue % 24;
                echo $byteValue."=24*".$hexPid[$j]."+".$digitMapIndex."<br>";
                echo "\$hexPid[".$j."]=".$hexPid[$j]."=0x".str_pad(strtoupper(dechex($hexPid[$j])),2, '0', STR_PAD_LEFT)."<br>";
                echo "\$digitMapIndex=".$digitMapIndex."<br>";   
                //echo "digitMapIndex=".$digitMapIndex."<br>";   
            }
            $decodedChars[$i] = $digits[$digitMapIndex];
            echo "\$ecodedChars[".$i."]=".$decodedChars[$i]."<br>";
        }
    }
  echo "<br>"."<br>";
  for ( $i=0;$i <= $decodeLength - 1; $i++)
    {
       echo $decodedChars[$i];
    }
        
//print_r($decodedChars);

 ?>

$i=28

$hexPid= 0=C2 1=49 2=4B 3=CC 4=60 5=34 6=09 7=CD 8=96 9=F7 10=EC 11=94 12=0E 13=97 14=02

--------$j=14

$byteValue=0x002=2

2=24*0+2

$hexPid14=0=0x00

$digitMapIndex=2

--------$j=13

$byteValue=0x297=663

663=24*27+15

$hexPid13=27=0x1B

$digitMapIndex=15

--------$j=12

$byteValue=0x150E=3854

3854=24*160+14

$hexPid12=160=0xA0

$digitMapIndex=14

--------$j=11

$byteValue=0x1494=3732

3732=24*155+12

$hexPid11=155=0x9B

$digitMapIndex=12

--------$j=10

$byteValue=0x12EC=3308

3308=24*137+20

$hexPid10=137=0x89

$digitMapIndex=20

--------$j=9

$byteValue=0x20F7=5367

5367=24*223+15

$hexPid9=223=0xDF

$digitMapIndex=15

--------$j=8

$byteValue=0x1596=3990

3990=24*166+6

$hexPid8=166=0xA6

$digitMapIndex=6

--------$j=7

$byteValue=0x6CD=1741

1741=24*72+13

$hexPid7=72=0x48

$digitMapIndex=13

--------$j=6

$byteValue=0x1309=3337

3337=24*139+1

$hexPid6=139=0x8B

$digitMapIndex=1

--------$j=5

$byteValue=0x134=308

308=24*12+20

$hexPid5=12=0x0C

$digitMapIndex=20

--------$j=4

$byteValue=0x2060=5216

5216=24*217+8

$hexPid4=217=0xD9

$digitMapIndex=8

--------$j=3

$byteValue=0x8CC=2252

2252=24*93+20

$hexPid3=93=0x5D

$digitMapIndex=20

--------$j=2

$byteValue=0x204B=5195

5195=24*216+11

$hexPid2=216=0xD8

$digitMapIndex=11

--------$j=1

$byteValue=0x1149=2889

2889=24*120+9

$hexPid1=120=0x78

$digitMapIndex=9

--------$j=0

$byteValue=0x9C2=2498

2498=24*104+2

$hexPid0=104=0x68

$digitMapIndex=2

$ecodedChars28=D

$i=27

$hexPid= 0=68 1=78 2=D8 3=5D 4=D9 5=0C 6=8B 7=48 8=A6 9=DF 10=89 11=9B 12=A0 13=1B 14=00

--------$j=14

$byteValue=0x000=0

0=24*0+0

$hexPid14=0=0x00

$digitMapIndex=0

--------$j=13

$byteValue=0x01B=27

27=24*1+3

$hexPid13=1=0x01

$digitMapIndex=3

--------$j=12

$byteValue=0x3A0=928

928=24*38+16

$hexPid12=38=0x26

$digitMapIndex=16

--------$j=11

$byteValue=0x169B=4251

4251=24*177+3

$hexPid11=177=0xB1

$digitMapIndex=3

--------$j=10

$byteValue=0x389=905

905=24*37+17

$hexPid10=37=0x25

$digitMapIndex=17

--------$j=9

$byteValue=0x17DF=4575

4575=24*190+15

$hexPid9=190=0xBE

$digitMapIndex=15

--------$j=8

$byteValue=0x15A6=4006

4006=24*166+22

$hexPid8=166=0xA6

$digitMapIndex=22

--------$j=7

$byteValue=0x2248=5704

5704=24*237+16

$hexPid7=237=0xED

$digitMapIndex=16

--------$j=6

$byteValue=0x168B=4235

4235=24*176+11

$hexPid6=176=0xB0

$digitMapIndex=11

--------$j=5

$byteValue=0x110C=2828

2828=24*117+20

$hexPid5=117=0x75

$digitMapIndex=20

--------$j=4

$byteValue=0x20D9=5337

5337=24*222+9

$hexPid4=222=0xDE

$digitMapIndex=9

--------$j=3

$byteValue=0x95D=2397

2397=24*99+21

$hexPid3=99=0x63

$digitMapIndex=21

--------$j=2

$byteValue=0x21D8=5592

5592=24*233+0

$hexPid2=233=0xE9

$digitMapIndex=0

--------$j=1

$byteValue=0x078=120

120=24*5+0

$hexPid1=5=0x05

$digitMapIndex=0

--------$j=0

$byteValue=0x068=104

104=24*4+8

$hexPid0=4=0x04

$digitMapIndex=8

$ecodedChars27=M

$i=26

$hexPid= 0=04 1=05 2=E9 3=63 4=DE 5=75 6=B0 7=ED 8=A6 9=BE 10=25 11=B1 12=26 13=01 14=00

相关推荐
sitelist10 个月前
DigitalProductId解密算法的一个例子
digitalproducti·igitalproductid