PHP加密解密类实例代码_php实例
程序员文章站
2022-04-10 18:10:27
...
关键代码如下所示:
$row){ if($columnKeyIsNumber){ $tmp= array_slice($row, $columnKey, 1); $tmp= (is_array($tmp) && !empty($tmp))?current($tmp):null; }else{ $tmp= isset($row[$columnKey])?$row[$columnKey]:null; } if(!$indexKeyIsNull){ if($indexKeyIsNumber){ $key = array_slice($row, $indexKey, 1); $key = (is_array($key) && !empty($key))?current($key):null; $key = is_null($key)?0:$key; }else{ $key = isset($row[$indexKey])?$row[$indexKey]:0; } } $result[$key] = $tmp; } return $result; }else{ return array_column($input, $columnKey, $indexKey); } } function randcode($len, $mode = 2){ $rcode = ''; switch($mode){ case 1: //去除0、o、O、l等易混淆字符 $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnpqrstuvwxyz'; break; case 2: //纯数字 $chars = '0123456789'; break; case 3: //全数字+大小写字母 $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; break; case 4: //全数字+大小写字母+一些特殊字符 $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz~!@#$%^&*()'; break; } $count = strlen($chars) - 1; mt_srand((double)microtime() * 1000000); for($i = 0; $i 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { return substr($result, 26); } else { return ''; } } else { return $keyc.str_replace('=', '', base64_encode($result)); } }
以上所述是小编给大家介绍的PHP加密解密类实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!