Download the PHP package italix/crypto without Composer

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

Italix Crypto

PHP Version

Signed expiring tokens, authenticated encryption, and rate limiting. Key rotation is built in rather than bolted on, because a key you cannot replace is a key you will not replace.

Zero Composer dependencies: ext-hash and ext-json are always present, ext-sodium ships with PHP ≥ 7.2 and is only needed for Cipher.


Setting up

The limiter needs no key. Signer and Cipher do, and the DI entries are lazy, so an application that only rate-limits never has to set one.


Rate limiting

Count before you check the password. A wrong guess must cost an attempt whether or not the account exists, otherwise the limiter itself becomes an oracle for which addresses are registered.

Reset after a successful login, or a user who mistypes four times and then succeeds is one typo from a lockout tomorrow.

Use two keys. They defend against different attacks and neither substitutes for the other:

Key Stops Costs
login:{email} one account being guessed nothing — an attacker just moves to the next account
login-ip:{ip} one host working through many accounts everyone behind one NAT shares the budget

A typical login applies both: 5 per account and 20 per IP, in a 15-minute window.

peek() reads the counter without incrementing — for showing the state on a GET without the page view itself counting.

The trade-off, stated up front

The window is fixed, not sliding: it opens at the first hit and lasts the full duration. Five attempts at 14:59 and five more at 15:01 are ten in two minutes against a limit of five per fifteen. That is asserted in the test suite so nobody discovers it by surprise. For making credential stuffing expensive it does not change the economics; if it ever matters, KeyValueStore is where a token bucket goes.

Keys are hashed before storage — the store is a table that outlives the request and may be dumped, and an e-mail address has no business being in it.


Signed tokens

The purpose is not decoration. Without it, a token minted to confirm an e-mail address can be replayed to reset a password. sign() refuses an empty purpose.

The payload is readable, and that is expected. Signing proves nobody changed it; it does not hide it. Put nothing in a token you would not put in the URL — because it is in the URL.

Verification order is signature → expiry → purpose, and it matters: deciding whether a token has expired by reading an unverified payload is trusting data the attacker wrote. A token that is both expired and tampered reports tampered.

When not to use this

A signed token is stateless: nothing is stored, and nothing can revoke it before it expires. For a password reset that is usually the wrong shape — the link should die the moment it is used, which needs a row.

The usual bin2hex(random_bytes(32)) tokens, stored against a row and cleared on use, are the right design for that and should stay. This is for the cases with nothing to revoke: an unsubscribe link, a signed download URL, state carried through a third-party redirect.


Encryption

libsodium crypto_secretbox — XSalsa20 plus Poly1305, one call, no mode or IV to choose wrong. Two encryptions of the same value differ. decrypt() returns the same null for every failure: a caller able to distinguish "wrong key" from "corrupt" is an oracle, and there is nothing different to do anyway.

Encrypted at rest protects against a stolen database dump and nothing else — the key is in .env on the same machine. Worth doing for an IBAN; not a reason to keep data that could be discarded. Never for passwords: those are password_hash(), and reversibility is the wrong property.


Key rotation

Sign with the primary, verify against all. Keep the old key until everything signed with it has expired, then delete the line — Claims::key_id() tells you which key verified a token, so a log shows when the old one stops being used. For encrypted columns, needs_rotation() identifies values still on the old key so they can be re-encrypted in a background pass.

Dropping the old key genuinely invalidates its tokens; there is a test asserting that, because a rotation that leaves the old key working has not rotated anything.


Deliberately not


All versions of crypto with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-hash Version *
ext-json Version *
italix/contracts Version ^2.0
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 italix/crypto contains the following files

Loading the files please wait ...