Download the PHP package nmure/encryptor without Composer

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

NmureEncryptor

Build Status Coverage Status

PHP data encryptor using open_ssl

Table of contents

Installation

Use composer to install the lib :

Usage

Basic usage

Encrypt

The simpliest way to use this library is to create an instance of the Encryptor by passing it a secret key and a cipher method to use during encryption. To see all the cipher methods supported by your php installation, use the openssl_get_cipher_methods function.

Then you can encrypt your plain text data, for instance :

The encryptor uses an Initialization Vector (IV) in addition to the secret key to encrypt data. This IV is randomly generated to be sure that 2 encryptions of the same data with the same key won't produce the same encrypted output.

Thereby, you should store the IV used to encrypt your data along side to the encrypted data to be able to decrypt it later.

For instance, you could store it in a database :

Decrypt

Then, to decrypt your data, initialize the encryptor and call the decrypt function :

Advanced usage

If you don't want to deal with how to store the encrypted data and the IV, you can use the formatters. The formatters combine the IV and the encrypted data into one string to make it easier to store and to share with an other app.

For instance, if you want to store an encrypted data to a file, you could use the Base64Formatter :

Then, to decrypt your data, use the same encryptor / formatter couple and simply call the decrypt function with the combined string :

If you don't want to use the formatter anymore, simply set it to null on the encryptor :

Using formatters is more convenient as all the work to store the IV along side the encrypted data is done by the formatters, and not by you anymore.

Formatters

The formatters are used to combine the IV and the encrypted data into one string (usually a non binary string), to make it easier to store and to share accross systems. They all implement the FormatterInterface.

Built-in formatters

Base64Formatter

The string returned by the Base64Formatter during the encryption process contains the base64 encoded IV, concatened to a colon (:), concatened to the base64 encoded encrypted data.

As the colon is not a char from the base64 chars, we can easily split this string in two parts from the colon, and get back the IV and the encrypted data during the decryption process.

HexFormatter

The string returned by the HexFormatter during the encryption process contains the hex representation of the concatened IV and encrypted data binary string.

During the decryption process, this string is splitted to get back the IV and the encrypted data. We use the cipher method's IV length to determine where to split this string.

Make your own formatter

You can of course make your own formatter to suit your needs, it must just implement the FormatterInterface.

API

Troubleshooting

Using the HexFormatter with a C# app

If you use this formatter with the encryptor to share crypted data with a C# app, you'll probably have to turn your secret key into a binary key :

Integration

You can use this library as standalone, or if you're using Symfony, it is wrapped inside the NmureEncryptorBundle.

Development / Contributing

Installing ecosystem

Testing

The formatters test classes should extend the AbstractFormatterTest class to be sure that the formatters fulfill the minimum requirements.

PHP CS Fixer

License

This library is licensed under the MIT License. More informations in the LICENSE file.


All versions of encryptor with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
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 nmure/encryptor contains the following files

Loading the files please wait ....