Download the PHP package drewlabs/crypt without Composer

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

Crypt

Crypt is PHP composer based package providing hashing and encryption classes, and methods, based on PHP default hashing & encryption methods.

Installation

Simply use composer PHP dependencies manager to install the package. If there is no composer installation on your operating system, you should be able to install the utility using this guide [https://getcomposer.org/download/].

Once composer is intalled on your operating system, run the comand below in your terminal at the root of your project:

composer require drewlabs/crypt

The above command will add drewlabs/crypt package and it dependencies to your project.

Usage

Encrypting a raw string

Note By default Crypt::new() generate a random key and use AES-128-CBC as cipher type. To override the defaults:

Note Supported cipher type are:

Note If the key is a base64 string, crypt library will try to decode the base64 string before creating the encryption key internally:

To get the plain text from an encrypted string, simply call the decryptString() method on the encrypted text:

The Crypt also class provides methods/functions for entrypting an entire file and decrypt the file from back to it original state. Below are the API for encrypting and decrypting files on a disk:

HMAC Hashing

HMAC hashing provides methods for creating hash and checking a raw value against a hash using user defined algorightm. To create a hash value:

Note By default, hashed value are created from strings. But the Hmac implementation supports PHP arrays, and serializable objects (classes having a toArray()). If the object does not have a toArray() method, the hashing implementation call get_object_vars on the object to convert the object into array, before hashing it.

Note To create a hash object from existing raw hashed string use the Hash::raw() method:

To check a hashed value against a new plain text value, first you create the hash object from raw hashed value and then you call the check() method against the plain text.

Note By default the library uses sha256 algorightm when creating hash values. PHP base function hash_algos returns the list of supported hash algorithm.

Note Below is the api for hashing a value:

Password encryption

The package also comes with implementation for creating md5, argon2, argon2i and bcrypt hash from plain text. It internally uses PHP password_hash function for creating hash. They are recommended for hashing password for user applications. To create a password hash from plain text:


All versions of crypt with dependencies

PHP Build Version
Package Version
Requires tuupola/base62 Version ^2.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 drewlabs/crypt contains the following files

Loading the files please wait ....