Download the PHP package maymeow/cryptography without Composer

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

MayMeow/Cryptography

[!IMPORTANT] Upcomming Version 2.0 introduces a new minimum PHP version requirement: PHP 8.4. This is a major change that may break existing functionality in your application if you are currently running an older PHP version. I highly recommend reviewing your environment and planning for this upgrade. Follow Discussion for upcomming update

ko-fi

Cryptographic library for encrypting and decrypting data the symetrical and asymetrical way.

This package replaces https://github.com/MayMeow/php-encrypt

PHP Composer

Requirements

What it is contained

⚠️ Breaking Changes - EC Migration

Version 1.x has migrated from RSA to Elliptic Curve (EC) cryptography as the default.

What Changed

Migration Guide

If you only use signing/verification: No changes needed - your code will automatically use faster EC keys.

If you use encryption/decryption: You have two options:

  1. Recommended: Use AES hybrid encryption (more secure, works with EC keys)
  2. Quick fix: Explicitly use RSA keys (maintains old behavior)

Note: The current AESCryptoServiceProvider::seal() method uses openssl_seal() which only supports RSA keys. EC-compatible hybrid encryption would require ECDH key exchange implementation.

New EC Classes Available

Development

This project contains dev container. To start development build container

This container running as user vscode with uid 1000. Start container

or it can be used as configuration for remote PHP processor in PHPStorm.

Usage

Symmetrical encryption

Using one key for encrypt and decrypt data. This library has default method set to aes-256-gcm

Encrypt text as follows

And then you can decrypt text as example shows bellow

Keep your key safe because you need it to decrypt data. You don't need to remember IV (initialization vector) because it is generated for each encryption, and then it is part of encrypted data.

Asymmetrical encryption

⚠️ Important Change: Default key generation now uses EC (Elliptic Curve) keys instead of RSA keys for better performance and security.

Digital Signatures (Works with both RSA and EC)

Digital signatures work seamlessly with both RSA and EC keys:

Data Encryption (RSA Keys Only)

For data encryption/decryption, you need to explicitly use RSA keys:

Hybrid Encryption (Future Enhancement)

Note: Current AES seal/open requires RSA keys. For EC-compatible hybrid encryption:

Using Dedicated EC Classes

For explicit EC usage, use the dedicated EC classes:

Exporting and importing keys

To use keys for later in case of encrypt/decrypt data is important to store them on some place. For this I created Readers and Writers. To export keys use Writer as example shows bellow:

If you want implement own Writers they must implement MayMeow\Cryptography\Tools\RsaParametersWriterInterface.

Importing keys can be done as on example below:

Like on writers you can implement your own Readers too. If you do so your new reader have to implement MayMeow\Cryptography\Tools\RsaParametersReaderInterface

Locators

Both reader and writer in above example is using Locator. Locators are classes which can return string representation of location where are stored RSAParameters parts. This can be database table, model, table field, path in filesystem and more. Interfaces for Reader and Writer not required to use one, but I recommend it.

If you want implement your own locator, this has to implement MayMeow\Cryptography\Tools\RSAParametersLocatorInterface.

As example, you can check Tools in test folder.

Cryptographic key derivation

Contribute

Feel free to contribute to this project. For contribution guide please check https://github.com/MayMeow/contribution

License MIT


All versions of cryptography with dependencies

PHP Build Version
Package Version
Requires php Version 8.0.*
ext-openssl 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 maymeow/cryptography contains the following files

Loading the files please wait ....