Den*_*nis 1 php encryption hash
我试图找出一种加密用户 ID 号的方法。我的想法是将 id(1 到 5 个字符之间)与一些字母(如 _wordtouse )结合起来加密。唯一的两个要求是
所有这一切的原因是当有人输入用户个人资料时,我试图“隐藏”用户 ID 号。所以我试图找到一种方法来通过 url 作为获取参数传递用户 ID 的加密版本。
有没有人知道如何解决这个问题?
我建议只使用非常流行的hashids 库以及许多 url 缩短服务使用的库。虽然它不是真正的“加密”,但它可能足以在 url 中隐藏用户的 ID 号。例子:
$userID = 1234;
$hashids = new Hashids\Hashids('some random secret string');
//encode the user id
$encodedID = $hashids->encode($user_id);
//on the other page, decode the user id
$decodedID = $hashids->decode($encodedID);
Run Code Online (Sandbox Code Playgroud)