zackkitzmiller / tiny-php

A reversible base62 ID obfuscater

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blacklist certain keys

Andreyco opened this issue · comments

Allow user to create list of keys that should never be generated.
E.g. "me", which could be problematic for lot of cases. Right now, "me" is decoded into 3716.

Sure, this could be handled out of this package, but it would be error prone. Better solution is to know Tiny won't generate "me", never.

Is it even possible?

This isn't really possible nor how this library is meant to work. You'd have to complete exclude seeming random integers from your PK generation.

The flow would have look something like:

  • Write a row to your DB
  • see if the Tiny'd PK resolves to 'me'
  • if it does, re-write db record for the next PK

Which is pretty crazy.

I'm guessing you're trying to build out a Facebook style /me endpoint. Is that the case?

I thought so - once Integer is hashed into "me", I will be hashed to very same value no matter what (if it should be decode later)

You are completely right, I am building /me endpoints.

Before Tiny, I was using Hashids, which could generate hash with minimal length as specified.
Looks like I will have to update row in database in this case.

FWIW, I'd recommend /me and /users/ID to be separate routes, but that's certainly unrelated to this project.

I also thing Hashids is a wonderful project, so please use it if you find that it's a better fit for you.

I'm going to close this for now. Have a great day.

Thank you, sticking with Tiny.