php - Hide mysql AI UID's, unique and not unique results, always same length -
i need convert mysql auto-increment bigint uid's (1-20 digit) strings of same length public displaying , url's (hiding real uid).
i need create 3 variants, 1 creates same encrypted string each time per id (these must same length (10-50 alphanumeric)), 1 creates different/random string each time id displayed never same can still retrieved (these must same length (10-50 alphanumeric)). last short id (for user id's), displaying least amount of characters (compressed string), alphanumeric, same per id (always same length, short possible); 1 created once per session can take longer or use more resources create.
// method 1 $id = '1'; displayed: 64359b7192746a14740a (same each time, id's displayed @ same length) // method 2 $id = '1000000000000000000'; displayed: 746a14740ad4bb7afe4eht36nh 146a7492719b3564094eyu8o0p fe7abbd40a7416fd90012fvd3e (different each time, id's displayed @ same length) // method 3 $userid = '2598624451675864259'; displayed: aw8qg07nzq (same each time, id's displayed @ same length)
i need basic 2 way encryption or encoding method, speed/less resources priority on security, should not guessable avoid counting id's determine activity.
i tried md5 hash dont want md5 search or store hash in db. have tried other numeric ways, padding id's 20, end longer wanted 60 character strings. tried using base_convert numeric id's long , max out.
if can point me right way of these appreciate it.
abandon having id in first place. create random, such as
mysql> select md5(now()); +----------------------------------+ | md5(now()) | +----------------------------------+ | 9fc432bc91593e8beaf6ffb5b9bf83a0 | +----------------------------------+ 1 row in set (0.00 sec)
then use string primary key
. md5
, example one-way, argue that not matter. avoiding 2-way hacker playing around ids don't belong him.
if md5 long, pick shorter, check dups when new "id" given out.
as long user , urls give 9fc432bc91593e8beaf6ffb5b9bf83a0
, there question decryption speed -- lookup.
Comments
Post a Comment