php版getFinalKey实现代码

发布时间:2019-11-22编辑:脚本学堂
分享一例php实现的getFinalKey代码,一个自定义的php函数,有需要的朋友参考下。

完整代码:
 

复制代码 代码示例:

<?php
//调用示例
echo getFinalKey('f9f3c542904bfcd5106bc9c525310a47aedaf692d918ebb0',1150); 

//getFinalKey函数
function getFinalKey($gKey, $gScore){ 
    if(!$gKey || !isset($gScore)){ 
        return (null); 
    } // end if 
    if(strlen($gKey) != 48){ 
        return (null); 
    } // end if 
    $gScore = (int) ($gScore); 
    if($gScore > 999999999){ 
        return (null); 
    } // end if 
    $_loc10 = $gKey; 
    $gKey = substr($gKey, 42, 6); 
    //$_loc8 = base_convert($gKey, 36, 10); 
    $_loc8 = parseInt($gKey, 36); 
    $_loc4 = toString($_loc8, 35); 
    $_loc13 = strlen($_loc4); 
    $_loc3 = parseInt(substr($gKey, strlen($gKey) - 1), 36) % $_loc13; 
    $_loc6 = toString($gScore, 36); 
    $_loc12 = substr($_loc4, 0, $_loc3); 
    $_loc7 = substr($_loc4, $_loc3); 
    $_loc5 = $_loc3 + 10; 
    $_loc11 = $_loc5 + strlen($_loc6); 
    $_loc9 = array(toString($_loc5, 36), $_loc12, $_loc6, $_loc7, toString($_loc11, 36));//, $_loc10 
    return (implode(',', $_loc9)); 

$key = 'avy1eo98acf9f3c542904bfcd5106bc9c525310a47aedaf692d918ebb0'; 
 
function deFinalKey($gKey){ 


 
//parseInt 
function parseInt($string, $radix = '0'){ 
    return base_convert($string, $radix, 10); 
}

function toString($string, $radix = '0'){ 
    return base_convert($string, 10, $radix); 
}