/    Sign up×
Community /Pin to ProfileBookmark

Best way to make a two-way key, generated from a String, that can be converted back?

Hi, our site needs to make a url resource harder to guess. Currently, we have userID’s like “10076”, which are sent in a query strings to access resources. I have this suggestion from a colleague:

“Upon login, instead of a userID, create a longer key (maybe 64-bytes of hex chars), that isn’t guessable within our lifetimes. (that’s twice the length of GUID, which is called Global Unique Identifier for a reason). The key needs to be a two-way key, so it needs to be created from a userID, and it needs to be convertible back to userID”

What is the method or function to create this two-way key, and convert it back?

Thanks.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 10.2009 — See the [url=http://php.net/mcrypt]mcrypt extension[/url] for encryption/decryption functions. You may need to combine it with base64encode()/base64decode() to use the encrypted values in URLs (or possibly urlencode() as well).
×

Success!

Help @decibel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...