加密部分。可以自己设置一个key作为秘钥
public function setUuid($uid = 123456, $startLength = 8){ if(empty($uid)) return false; $uid = base64_encode($uid); $uuid = $this->encrypt($uid); $uuid = str_replace('=', '', $uuid); return substr($uuid, 0, $startLength) . '-' . substr($uuid, $startLength, 4) . '-' . substr($uuid, $startLength+4, 4) . '-' . substr($uuid, $startLength+8, 4) . '-' . substr($uuid, $startLength+12); } 输出 6MKGLi4Y-bY5X-AhKf-JaG1-Fg
解密部分
public function getUidByUuid($uuid){ $strCount = substr_count($uuid,'-'); $uuid = explode('-', $uuid); $uid = ''; for ($i = 0; $i <= $strCount; $i++){ $uid .= $uuid[$i]; } return base64_decode($this->decrypt($uid)); } 输出123456
=================