Download the PHP package gbhorwood/redactem without Composer

On this page you can find all versions of the php package gbhorwood/redactem. 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 redactem

Redactem

License Version PHP Version Require

Redactem is php package for redacting values from json. If you need to scrub out passwords or credit card numbers, or the value of any key/value pair identified by key or regular expression, from a string of json before writing it to disk or db, Redactem can do that.

Redactem was developed as an internal-use tool for fruitbat studios/cloverhitch technologies/kludgetastic implementations.

Install

Redactem is installed via composer:

Then, in your script, require and use:

Features

Redactem finds and replaces values in json with a chosen or default redaction text. Replacements are done to an arbitrary depth in nested strucutres. Valid json stored as strings is also processed.

Finding values to redact can be done by key name, case sensitive or insensitive, or by regular expression matches on values. Redactem offers convenience methods to redact passwords, credit card number, or emails, but also allows you to write your own rulesets.

Before basic password redaction:

After:

Redacting passwords

Redacting passwords can be done with the passwords() convenience method:

This method redacts all values keyed with the following:

If you have password data that is keyed with a different key than listed, you can use the byKey() method.

Password values are replaced by default with '*****' (five asterisks). If you would like to set a custom redaction text, passwords() takes a redaction text as an optional second argument.

Redacting credit card numbers

Redacting credit card numbers can be done with the creditcards() convenience method:

Credit card numbers are identified by a regular expression that matches major credit card vendor's patterns.

Credit card values are replaced with a redaction text of asterisks the length of the credit card number. If you would like to set a custom redaction text, creditcards() takes a redaction text as an optional second argument.

Redacting emails

Redacting email addresses can be done with the emails() convenience method:

Email address are matched using php's filter_var() function with FILTER_VALIDATE_EMAIL.

Email values are replaced with a partial redaction of the email, allowing it to be recognized by readers that already know the email address. For instance, the email address [email protected] would be redacted as gb*****od@ex***le.ca. If you would like to set a custom redaction text, emails() takes a redaction text as an optional second argument.

Custom redactions by key

Redactions can be done by specifying a key of a key/value pair to redact:

By default, keys are treated as case insensitive. If you wish to enable case sensitivity, pass true as an optional third argument

The default behaviour is to redact values with the default redaction text of ***** (five asterisks). A custom redaction text can be supplied as an optional fourth argument

Redactions can be done for multiple keys by calling byKeys and passing an array of keys:

The byKeys method behaves identically to the byKey method, the only difference being the second argument is an array of keys.

Custom redactions by regex

Redactions can be done by supplying a regular expression to match values to redact

Regular expressions supplied to byRegex() are matched against values using php's preg_match().

The default behaviour is to redact values with the default redaction text of ***** (five asterisks). A custom redaction text can be supplied as an optional third argument

Writing custom redaction rules

Redactem's behaviour can be customized by using the base function redact().

The redact() function accepts three arguments:

A usage example is:

This example will accept input of json that looks like:

And return:


All versions of redactem with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 gbhorwood/redactem contains the following files

Loading the files please wait ....