Download the PHP package robtimus/obfuscation without Composer

On this page you can find all versions of the php package robtimus/obfuscation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package obfuscation

Obfuscation

Packagist Version Build Status Quality Gate Status Coverage

Provides functionality for obfuscating text. This can be useful for logging information that contains sensitive information.

Obfuscating strings

Pre-defined obfuscators

The following pre-defined obfuscators are provided that all return an immutable obfuscator.

Obfuscate::all

Replaces all characters with a mask character that defaults to *.

Note: using this obfuscator still leaks out information about the length of the original text. One of the following two is more secure.

Obfuscate::fixedLength

Replaces the entire text with a fixed number of the given mask character that defaults to *.

Obfuscate::fixedValue

Replaces the entire text with a fixed value.

Obfuscate::portion

While the above examples are simple, they are not very flexible. Using Obfuscate::portion you can build obfuscators that obfuscate only specific portions of text. Some examples:

Obfuscating all but the last 4 characters

Useful for obfuscating values like credit card numbers.

It’s advised to use atLeastFromStart, to make sure that values of fewer than 16 characters are still obfuscated properly:

Obfuscating only the last 2 characters

Useful for obfuscating values like zip codes, where the first part is not as sensitive as the full zip code:

Here, the keepAtStart instructs the obfuscator to keep everything; however, atLeastFromEnd overrides that partly to ensure that the last two characters are obfuscated regardless of the value specified by keepAtStart.

Using a fixed length

Similar to using Obfuscate::all, by default an obfuscator built using Obfuscate::portion leaks out the length of the original text. If your text has a variable length, you should consider specifying a fixed total length for the result. The length of the result will then be the same no matter how long the input is:

Note that if keepAtStart and keepAtEnd are both specified, parts of the input may be repeated in the result if the input’s length is less than the combined number of characters to keep. This makes it harder to find the original input. For example, if in the example foo would be obfuscated into fo***o instead, it would be clear that the input was foo. Instead, it can now be anything that starts with fo and ends with oo.

Obfuscate::none

Does not perform any obfuscation at all. It can be used as default to prevent checks. For instance:

Obfuscate::exploded

Explodes the text to an array, obfuscates each element, then implodes the array again.

Combining obfuscators

Sometimes the obfucators in this library alone cannot perform the obfuscation you need. For instance, if you want to obfuscate credit cards, but keep the first and last 4 characters. If the credit cards are all fixed length, Obfuscate::portion can do just that:

However, if you attempt to use such an obfuscator on only a part of a credit card, you could end up leaking parts of the credit card that you wanted to obfuscate:

To overcome this issue, it’s possible to combine obfuscators. The form is as follows:

For instance, for credit card numbers of exactly 16 characters, the above can also be written like this:

With this chaining, it’s now possible to keep the first and last 4 characters, but with at least 8 characters in between:

Splitting text during obfuscation

To make it easier to create obfuscators for structured text like email addresses, use a SplitPoint. Three implementations are provided :

For instance:

To obfuscate the domain except for the TLD, use a nested SplitPoint:

Custom obfuscators

To create a custom obfuscator, create a sub class of Obfuscator, override its constructor and implements its obfuscateText method. For instance:

Obfuscating object properties

Use PropertyObfuscator::builder to start creating objects that can obfuscate single object properties as well as recursively all properties in an object or array.

The simplest form provides an obfucator for each property to obfuscate:

This matches property names case sensitively, and for any nested objects or arrays will obfuscate any scalar property with the object's or array's obfuscator. This behaviour can be changed in two ways:

  1. Per property. withProperty returns an object that can be used to further configure the property:

  2. Using global options:

In both cases, forObjects and forArrays can take the following values:

Obfuscating HTTP headers

Use HeaderObfuscator::builder to start creating objects that can obfuscate single HTTP headers (as strings and string arrays) and associative arrays containing multiple headers. It's much like PropertyObfuscator, but like HTTP headers it's always case insensitive. Unlike PropertyObfuscator, it doesn't support nested objects, and for nested arrays each element is obfuscated separately. It also does not support skipping obfuscation.


All versions of obfuscation with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package robtimus/obfuscation contains the following files

Loading the files please wait ...