spaze/encryption
spaze/encryption is a lightweight PHP library for symmetric encryption, offering a simple API to encrypt and decrypt strings and application data using secure cryptographic primitives, with key handling that fits easily into existing PHP projects.
AuthenticatedPublicKeyEncryption supports bidirectional encrypted exchange with sender authentication, while AnonymousPublicKeyEncryption supports write-only producers that hold only public keys. This is useful for ingest pipelines, partner integrations, telemetry collection, and services that must encrypt but must not be able to decrypt.FormatMarkerMismatchException and UnknownFormatMarkerException replace Halite exceptions for format errors.$keyId$... marked values before every reader is on v3, those readers will fail. Rollback after v3 writes is also risky because older versions cannot decrypt the new format. The re-encryption sweep is another risk: needsReEncrypt() now returns true for all pre-v3 values, so a broad sweep will touch all existing encrypted data; rows written with encryptWithAd() must be re-encrypted with the correct row additional data or decryption will fail. Asymmetric key handling introduces operational risk: a missing private key makes anonymous ciphertext unrecoverable by design, and a mismatched or missing key pair should fail at object creation, which is good but must be validated during deployment.prefix_secret_hex and prefix_public_hex where asymmetric keys are used so a key pasted into the wrong slot fails during object creation. Use AuthenticatedPublicKeyEncryption for two-party exchanges where both sides encrypt/decrypt and need sender authentication. Use AnonymousPublicKeyEncryption only for producer-only workflows where the writer should never be able to read back ciphertext.needsReEncrypt() sweep, and verify old and new values decrypt correctly. For encryptWithAd() rows, include the row’s additional data during re-encryption.InvalidMessage or InvalidNumberOfComponentsException so it also handles FormatMarkerMismatchException and UnknownFormatMarkerException. Confirm paragonie/halite 5.1+ resolves cleanly and that key casing is handled correctly; the release notes document keys as valid in lowercase or uppercase. Test decryption of legacy fixtures before enabling writes.AnonymousPublicKeyEncryption data cannot be decrypted by the producer and that lost private keys mean unrecoverable data by design. Re-encryption jobs need dashboards and alerting.FormatMarkerMismatchException and UnknownFormatMarkerException. Re-encrypting additional-data rows without the correct additional data will produce undecryptable values. Tampered markers, stripped markers, or forged markers should fail decryption, which is desirable but will surface as application errors if data is corrupted. The old-format key-ID tamper caveat remains only for values in the old format.How can I help you explore Laravel packages today?