paragonie/halite
High-level cryptography interface powered by libsodium
v5.1.4
11M downloads/mo
#1151 most downloaded on Packagist
paragonie/halite
What this package is like to depend on
Last release 11 months ago
19 Sep 2025
Release timing varies
gaps range from 3 weeks to 1.9 years
Some releases are documented
notes for 36 of 64 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
64 releases · first in 2015
1 release in the last 12 months
see the full history below
Release timeline
64 releases · Sep 2015 to Sep 2025Releases
latest 60 of 64-
v5.1.419 Sep 2025Release notes
Open source →- Add PHPStan analysis, level 5 by @spaze in #195
- Replace all
http://links with thehttps://URL they redirect to by @GrahamCampbell in #196 - Use Psalm 6 by @spaze in #198
- Remove access modifier
finalfrom private methods by @junaidbinfarooq in #204 - Ignore tests, workflows and .MD docs with "export-ignore" on .gitattr… by @erikn69 in #205
- Expand test coverage by @paragonie-security in #206
- Fixed the broken test coverage badge (#207 and #208)
Release notes
Open source →- Add PHPStan analysis, level 5 by @spaze in https://github.com/paragonie/halite/pull/195
- Replace all
http://links with thehttps://URL they redirect to by @GrahamCampbell in https://github.com/paragonie/halite/pull/196 - Use Psalm 6 by @spaze in https://github.com/paragonie/halite/pull/198
- Remove access modifier
finalfrom private methods by @junaidbinfarooq in https://github.com/paragonie/halite/pull/204 - Ignore tests, workflows and .MD docs with "export-ignore" on .gitattr… by @erikn69 in https://github.com/paragonie/halite/pull/205
- Expand test coverage by @paragonie-security in https://github.com/paragonie/halite/pull/206
- Fixed the broken test coverage badge (https://github.com/paragonie/halite/pull/207 and https://github.com/paragonie/halite/pull/208)
-
v5.1.323 Jan 2025Release notes
Open source →What's Changed
- Fix PHP 8.4 deprecations by @acbramley in #194
New Contributors
- @acbramley made their first contribution in #194
Full Changelog: v5.1.2...v5.1.3
-
v5.1.208 May 2024Release notes
Open source →- Use
#[SensitiveParameter]annotation on some inputs- This is defense in depth; we already wrapped most in
HiddenString
- This is defense in depth; we already wrapped most in
- Updated dependencies
Release notes
Open source →- Use
#[SensitiveParameter]annotation on some inputs- This is defense in depth; we already wrapped most in
HiddenString
- This is defense in depth; we already wrapped most in
- Updated dependencies
- Use
-
v5.1.119 Apr 2024 -
v5.1.023 May 2022Release notes
Open source →- Dropped PHP 8.0 support, increased minimum PHP version to 8.1.
- This is due to the significant performance difference between ext/sodium
and sodium_compat, and the functions we use in 5.x aren't available until
PHP 8.1. See #178.
- This is due to the significant performance difference between ext/sodium
- The 5.0.x branch will continue to function on PHP 8.0 but performance is
not guaranteed.
Release notes
Open source →- Dropped PHP 8.0 support, increased minimum PHP version to 8.1.
- This is due to the significant performance difference between ext/sodium and sodium_compat, and the functions we use in 5.x aren't available until PHP 8.1. See #178.
- The 5.0.x branch will continue to function on PHP 8.0 but performance is not guaranteed.
- Dropped PHP 8.0 support, increased minimum PHP version to 8.1.
-
v5.0.019 Jan 2022Release notes
Open source →- Increased minimum PHP version to 8.0.
- Security: Asymmetric encryption now uses HKDF-BLAKE2b to extract a 256-bit uniformly random bit string for the encryption key, rather than using the raw X25519 output directly as an encryption key. This is important because Elliptic Curve Diffie-Hellman results in a random group element, but that isn't necessarily a uniformly random bit string.
- Because Halite v4 and earlier did not perform this step, it's superficially susceptible to Cheon's attack. This reduces the effective security from 125 bits (Pollard's rho) to 123 bits, but neither is a practical concern today.
- Security: Halite v5 uses the PAE strategy from PASETO to prevent canonicalization attacks.
- Security: Halite v5 appends the random salt to HKDF's
infoparameter instead of thesaltparameter. This allows us to meet the KDF Security Definition (which is stronger than a mere Pseudo-Random Function). - Encryption now uses XChaCha20 instead of XSalsa20.
- The
Fileclass no longer supports theresourcetype. To migrate code, wrap yourresourcearguments in aReadOnlyFileorMutableFileobject. - Added
File::asymmetricEncrypt()andFile::asymmetricDecrypt().
These security improvements were identified through an internal code review after years of studying new cryptographic attacks. Halite v4 ciphertexts are still decryptable with v5, so upgrading should be largely drop-in.
Release notes
Open source →- Increased minimum PHP version to 8.0.
- Security: Asymmetric encryption now uses HKDF-BLAKE2b to extract a 256-bit uniformly random bit string for the
encryption key, rather than using the raw X25519 output directly as an encryption key. This is important because
Elliptic Curve Diffie-Hellman results in a random group element, but that isn't necessarily a uniformly random bit
string.
- Because Halite v4 and earlier did not perform this step, it's superficially susceptible to Cheon's attack. This reduces the effective security from 125 bits (Pollard's rho) to 123 bits, but neither is a practical concern today.
- Security: Halite v5 uses the PAE strategy from PASETO to prevent canonicalization attacks.
- Security: Halite v5 appends the random salt to HKDF's
infoparameter instead of thesaltparameter. This allows us to meet the KDF Security Definition (which is stronger than a mere Pseudo-Random Function). - Encryption now uses XChaCha20 instead of XSalsa20.
- The
Fileclass no longer supports theresourcetype. To migrate code, wrap yourresourcearguments in aReadOnlyFileorMutableFileobject. - Added
File::asymmetricEncrypt()andFile::asymmetricDecrypt().
-
v4.9.015 Jul 2025Release notes
Open source →What's Changed
- Fixes documentation by @faizanakram99 in #172
- Remove php 8.4 deprecations by @akondas in #201
- Update CI configuration for v4.x branch by @paragonie-security in #202
- Fix CI by @paragonie-security in #203
New Contributors
- @faizanakram99 made their first contribution in #172
- @akondas made their first contribution in #201
Full Changelog: v4.8.0...v4.9.0
-
v4.8.018 Apr 2021Release notes
Open source →- Merged #158, which removes the
finalaccess modifier from private methods and guarantees PHP 8 support. - Migrated tests off of Travis CI, onto Github Actions instead.
Release notes
Open source →- Merged #158, which removes
the
finalaccess modifier from private methods and guarantees PHP 8 support. - Migrated tests off of Travis CI, onto Github Actions instead.
- Merged #158, which removes the
-
v4.7.106 Dec 2020 -
v4.7.003 Dec 2020 -
v4.6.012 Sep 2019Release notes
Open source →- Merged #138, which adds
remote stream support to
ReadOnlyFile. - Merged #140, which saves some overhead on hash recalculation.
- Merged #136 and #137, which updated the sodium stub files. These aren't strictly necessary anymore; with the adoption of libsodium in PHP 7.2 and sodium_compat, most IDEs autocomplete correctly. But fixing nits is always appreciated.
- Update minimum sodium_compat to v1.11.0.
- Merged #138, which adds
remote stream support to
-
v4.5.405 Jun 2019Release notes
Open source →- Merged #132, which ensures
all Halite exceptions implement
Throwable. - Merged #133, which updates
the documentation for the
FileAPI. Thanks @elliot-sawyer. - Merged #134, which allows
MutableFileto be used on resources opened inwbmode. Thanks @christiaanbaartse. - Other minor documentation improvements.
- Merged #132, which ensures
all Halite exceptions implement
-
v4.5.311 Mar 2019Release notes
Open source →- Fixed some minor nuisances with Psalm and PHPUnit.
- Added reference to Halite-Legacy to the README.
- Updated docblocks.
-
v4.5.211 Feb 2019Release notes
Open source →- Fixed #116. If the output file doesn't exist, it will be created. If it cannot be created, an exception will still be thrown.
-
v4.5.108 Jan 2019Release notes
Open source →- Use
class_alias()forParagonIE\Halite\HiddenStringto the outsourced library. This is deprecated and will be removed in version 5.
- Use
-
v4.5.003 Jan 2019Release notes
Open source →- Updated Psalm version from
^0|^1to^1|^2. - Moved
HiddenStringto a standalone library: https://travis-ci.org/paragonie/hidden-string
- Updated Psalm version from
-
v4.4.227 Mar 2018Release notes
Open source →- Updated Psalm version from
^0|^1to^1. - Type-safety and documentation fixes.
- Miscellaneous boyscouting. No bugs were found since 4.4.1.
- Updated Psalm version from
-
v4.4.127 Feb 2018 -
v4.4.004 Feb 2018Release notes
Open source →- Fixed #90:
- Introduced
WeakReadOnlyFile, an alternative toReadOnlyFilethat allows file modes other thanrb. The TOCTOU security guarantees are therefore slightly weaker with this class (hence the "Weak" part of the name). - Updated
Fileto allow stream objects (ReadOnlyFileandMutableFile) to be passed direclty instead of strings (for filenames) and resources (for open file handles).
- Introduced
- Fixed #90:
-
v4.3.130 Jan 2018Release notes
Open source →- Updated the
Halite::VERSIONconstant which was previously still4.2.0. - Documentation and unit testing improvements.
- Updated the
-
v4.3.026 Jan 2018Release notes
Open source →- You can now quickly turn a
SignatureKeyPairobject into a birationally equivalent EncryptionKeyPair object by invoking thegetEncryptionKeyPair()method. - We now have 100% unit test coverage, in addition to our static analysis.
- You can now quickly turn a
-
v4.2.015 Jan 2018Release notes
Open source →- Implemented
Asymmetric::signAndEncrypt()andAsymmetric::verifyAndDecrypt(), which facilitates the GPG use-case of signed-then-encrypted messages between two parties' Ed25519 keypairs. Encryption is facilitated using birationally equivalent X25519 keys. - Removed our in-house implementations of binary-safe
substrandstrlenin favor of using the ones in the constant-time encoding library.
- Implemented
-
v4.1.005 Jan 2018Release notes
Open source →Added support for libsodium 1.0.15, which was previously broken in 4.0.x.
Passwords should be autoamtically migrated, but if keys were being generated via
KeyFactory::derive______Key()(fill in the blank), you'll need to change your usage of this API to get the same key as previously. Namely, you'll need to pass theSODIUM_CRYPTO_PWHASH_ALG_ARGON2I13constant to the fourth argument after the password, salt, and security level.$key = KeyFactory::deriveEncryptionKey( new HiddenString('correct horse barry staple'), - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + KeyFactory::INTERACTIVE, + SODIUM_CRYPTO_PWHASH_ALG_ARGON2I13 );If you previously specified a security level, your diff might look like this:
$key = KeyFactory::deriveEncryptionKey( new HiddenString('correct horse barry staple'), "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", - KeyFactory::SENSITIVE + KeyFactory::SENSITIVE, + SODIUM_CRYPTO_PWHASH_ALG_ARGON2I13 ); -
v4.0.330 Jan 2018Nothing published for this version
-
v4.0.208 Dec 2017Release notes
Open source →This is mostly a boyscouting/documentation release. However, we now pass Psalm under the strictest setting (
totallyTyped = true). This means that not only is our public interface totally type-safe, but Halite's internals are as well. -
v4.0.119 Oct 2017Release notes
Open source →- Prompted by #67, Halite is now available under the terms of the Mozilla Public License 2.0 (MPL-2.0). Using Halite to build products that restrict user freedom (such as DRM) is highly discouraged, but not forbidden.
-
v4.0.016 Sep 2017Release notes
Open source →- Bump minimum PHP version to 7.2.0, which will be available before the end of 2017
- New methods:
encryptWithAd()anddecryptWithAd(), for satisfying true AEAD needs - Encrypted password hashing through our
Passwordclass can also accept an optional, additional data parameter HiddenStringobjects can now be directly compared$hiddenString->equals($otherHiddenString)
- Added Psalm to our Continuous Integration to assure Halite is fully type-safe
- Updated unit tests to be compatible with PHPUnit 6
-
v3.4.127 Mar 2018Nothing published for this version
-
v3.4.029 Jan 2018Release notes
Open source →This tag was signed with the committer’s verified signature .
paragonie-security P.I.E. Security Team
GPG key ID: 6B97A1C2826404DA
Verified Learn about vigilant mode .
e1c194e
- Fixes #89 . Please upgrade to v4.3.0 or higher as soon as possible. We will no longer be supporting Halite version 3.x or older for free. If you need ongoing support for a legacy version of Halite, please get in contact with Paragon Initiative Enterprises about purchasing a long-term support contract.
-
v3.3.019 Aug 2017Nothing published for this version
-
v3.2.008 Dec 2016Release notes
Open source →- Resolved #49, which
requested making
HiddenStringdefend againstserialize()leaks. - Fixed an encoding issue which broke legacy passwords. (Discovered in the course of CMS Airship development.)
- The
FileAPI now supports different encodings for signatures and checksums (more than just hex and binary).
- Resolved #49, which
requested making
-
v3.1.126 Oct 2016Release notes
Open source →- Fixed #44, which caused Halite to be unusable for Symfony users. Thanks, Usman Zafar.
-
v3.1.022 Aug 2016Release notes
Open source →- Added an
export()method toKeyFactory, and congruentimport*()methods. For example:export($key)returns aHiddenStringwith a versioned and checksummed, hex-encoded string representing the key material.importEncryptionKey($hiddenString)expects anEncryptionKeyobject or throws aTypeError
- Added an
-
v3.0.030 Jul 2016Release notes
Open source →- Use paragonie/constant_time_encoding
- We now default to URL-safe Base 64 encoding (RFC 4648)
- API change: Plaintext and password inputs must be a
HiddenStringobject. - Dropped support for version 1.
- We no longer offer or use scrypt anywhere. Everything is Argon2 now.
KeyFactoryno longer accepts a$legacyargument.
- Added
TrimmedMerkleTreetoStructures. - Use
is_callable()instead offunction_exists()for better compatibility with Suhosin.
-
v2.2.022 Aug 2016Nothing published for this version
-
v2.1.329 Jul 2016Nothing published for this version
-
v2.1.211 Jul 2016 -
v2.1.115 May 2016Release notes
Open source →- Prevent an undefined index error when calculating the root of an empty MerkleTree.
-
v2.1.007 May 2016Release notes
Open source →- Key derivation (via
KeyFactory) can now accept an extra argument to specify the security level of the derived key.- Scrypt:
INTERACTIVEorSENSITIVE - Argon2i:
INTERACTIVE,MODERATE, orSENSITIVE
- Scrypt:
Passwordcan now accept a security level argument. We recommend sticking withINTERACTIVEfor end users, but if you'd rather make administrative accounts cost more to attack, now you can make that happen within Halite.MerkleTreecan now accept a personalization string for the hash calculation.MerkleTreecan output a specific hash length (between 16 and 64).- Both
MerkleTreeandNodenow lazily calculate the Merkle root rather than calculating it eagerly. This results in less CPU waste. - Cleaned up the legacy cruft in the
Keyclasses. Now they only accept a string in their constructor.
- Key derivation (via
-
v2.0.121 Apr 2016Release notes
Open source →- Fixed conflict with PHP 7 string optimizations that was causing
File::decrypt()to fail in PHP-FPM. - Introduced a new method,
Util::safeStrcpy(), to facilitate safe string duplication without triggering the optimizer.
- Fixed conflict with PHP 7 string optimizations that was causing
-
v2.0.004 Apr 2016Release notes
Open source →- Halite now requires:
- PHP 7.0+
- libsodium 1.0.9+
- libsodium-php 1.0.3+
- (You can use
Halite::isLibsodiumSetupCorrectly()to verify the latter two)
- Strictly typed everywhere
- You can no longer pass a well-configured but generic
Keyobject to most methods; you must pass the appropriate child class (i.e.Symmetric\Crypto::encrypt()expects an instance ofSymmetric\Crypto\EncryptionKey. - Updated password hashing and key derivation to use Argon2i
Filenow uses a keyed BLAKE2b hash instead of HMAC-SHA256.Key->get()was renamed toKey->getRawKeyMaterial()Passwordnow has aneedsRehash()method which will returntrueif you're using an obsolete encryption and/or hashing method.Utilnow has several new methods for generating BLAKE2b hashes:hash()keyed_hash()raw_hash()raw_keyed_hash()
- Removed most of the interfaces in
Contract
- Halite now requires:
-
v1.6.001 Oct 2017Nothing published for this version
-
v1.5.129 Jul 2016Nothing published for this version
-
v1.5.008 Mar 2016Nothing published for this version
-
1.4.017 Feb 2016Nothing published for this version
-
1.3.217 Jan 2016Nothing published for this version
-
1.3.114 Jan 2016Nothing published for this version
-
1.3.030 Dec 2015Nothing published for this version
-
1.2.014 Nov 2015Nothing published for this version
-
1.1.006 Nov 2015Nothing published for this version
-
1.0.006 Nov 2015Nothing published for this version
-
0.8.103 Nov 2015Nothing published for this version
-
0.8.002 Nov 2015Nothing published for this version
-
0.7.030 Oct 2015Nothing published for this version
-
0.6.026 Oct 2015Nothing published for this version
-
0.5.321 Oct 2015Nothing published for this version
-
0.5.217 Oct 2015Nothing published for this version
-
0.5.115 Oct 2015Nothing published for this version
-
0.5.014 Oct 2015Nothing published for this version
-
0.4.014 Oct 2015Nothing published for this version