用户id加密

来源:互联网 发布:名片设计app软件 编辑:程序博客网 时间:2024/06/03 10:59

效果:加密用户id,防止id泄露

/** * 用户ID加密  hashid checkid 算法 */function hashUser($user, $downloadKey='') {    if (empty($user)) {        return '0';    }    $crc = intval(sprintf('%u', crc32($downloadKey . "asdfwrew.USER_SEED")));    $hash = $crc - $user;    $hash2 = sprintf('%u', crc32($hash . 'werhhs.USER_SEED2'));    $k1 = substr($hash2, 0, 3);    $k2 = substr($hash2, -2);    return $k1 . $hash . $k2;}$hashid = hashUser(2132, 'derfgfsdbz');
0 0