突然发现我曾经在公司用过的一个通信及接口,放给php的同事用的,有点幼稚
保存纪念一下
<?php /*使用方法,请将你的ip,我提供的key, 你的查询开始时间和结束时间两个参数连接起来 (IP.key.date1.date2) http://att.oa.com/one/{你计算出来的skey}/{date1}/{date2}/{工号可选} 传入下面一个参数进行计算, 返回四组数据的数据,然后取第一组数据+第三组数据,组成12位加密字符串skey, 我在服务端会有一个list,一个IP对应一个key的 */ $ip= '172.20.108.51'; ##(localhost) $key="clientHardie"; ##服务器(我方)提供对应IP的key $startTime= "2014-07-01"; ##查询开始时间 $endTime= "2014-07-02"; ##结束时间 $employeeID ="0129"; ##查询工号(可选) $eskey =encrypt($ip.$key.$startTime.$endTime); $skey = $eskey[0].$eskey[2]; $url= 'http://att.oa.com/one/'.$skey.'/'.$startTime.'/'.$endTime.'/'.$employeeID; echo $url; function encrypt($input) { $base32 = array ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ); $hex = strtoupper(md5($input)); $hexLen = strlen($hex); $subHexLen = $hexLen / 8; $output = array(); for ($i = 0; $i < $subHexLen; $i++) { $subHex = substr ($hex, $i * 8, 8); $int = 0x3FFFFFFF & (1 * ('0x'.$subHex)); $out = ''; for ($j = 0; $j < 6; $j++) { $val = 0x0000003D & $int; $out .= $base32[$val]; $int = $int >> 5; } $output[] = $out; } return $output; } ?>
文章评论