Download the PHP package craftwork/id-obfuscator without Composer
On this page you can find all versions of the php package craftwork/id-obfuscator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download craftwork/id-obfuscator
More information about craftwork/id-obfuscator
Files in craftwork/id-obfuscator
Package id-obfuscator
Short Description A base converter to obfuscate database IDs in front end applications
License MIT
Homepage https://github.com/craftwork/id-obfuscator
Informations about the package id-obfuscator
ID Obfuscator
A simple encoder to obfuscate database IDs.
This is particularly useful when you don't want to expose sensitive information about your application, for instance the number of users or orders.
Imagine having URLs like these:
then you can convert them into:
Note
This is not an encryption library and should not be used for security purposes.
It is not advisable saving encoded numbers but encoding and decoding IDs on the fly.
You can use a custom character set and a salt to shuffle the characters. Keep the salt private.
It is not advisable to change these at run time as some users might share or bookmark links. To ensure users don't end up on broken links always use the same character set and salt. If the links are restricted to logged in users it might be a good idea to use a user specific salt, such as a uuid.
Installation
Requirements
PHP 7.0.
Usage
Character sets
The default character set is bcdefghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ1234567890-_
. An additional character set
is also built in which only uses lowercase hexadecimal characters (CharacterSet::ofHexCharacters()
).
You can provide your own character set if you want to either limit the encoding to certain characters or use different characters. Characters need to be ASCII and the character set must be at least two characters long and not contain any duplicates.