tigr/compact-encrypter

Data encrypter producing compact and URL-safe output

1.0.0 2023-05-31 14:45 UTC

This package is auto-updated.

Last update: 2024-04-30 00:48:40 UTC


README

Travis (.org) PHP from Packagist Packagist Version GitHub

Simple compact encrypter

Installation

composer require tigr/compact-encrypter

Why?

It provides very concise encrypted URL-safe data. For instance, it could be used to create self-contained tokens that would contain all the necessary information inside.

How does it work?

  1. No intermediate base64 or hex encoding, all data is raw binary.
  2. No JSON, use pack()/unpack().
  3. Use URL-safe version of base64 (drop trailing '=', replace '/+' with '-_').
  4. For hashing, use SHA1 instead of SHA256. I know, I know, but for real-world purposes SHA1 is still good enough.
  5. Allow dropping Mac (validation hash) whatsoever if you want it really short.