phpseclib implements SSH, SFTP, X.509, and common symmetric and public-key algorithms in PHP without mandatory extensions. It optionally accelerates via OpenSSL, GMP, or libsodium when present.
Overview
phpseclib provides MIT-licensed PHP implementations of protocols and primitives developers import into applications for secure file transfer, remote shells, certificate handling, and encryption tasks. Coverage spans RSA, DSA, ECDSA, ECDH, Ed25519, AES family ciphers, ChaCha20-Poly1305, and related ASN.1 structures.
Multiple major branches target different PHP versions, from legacy 1.x through 4.x on PHP 8.1+, installed via Composer with PSR-4 namespaces per branch. Documentation and generated API references exist for each supported line.
The design emphasizes interoperability with standard libraries and portability when native extensions are unavailable, while using accelerators when the runtime provides them. Security reports route through Tidelift coordinated disclosure.
Use cases include SFTP integrations, SSH automation, and X.509 parsing in PHP-only environments.
Key features
- SSH-2 and SFTP client implementations
- RSA, DSA, and elliptic curve crypto
- AES, ChaCha20, and legacy ciphers
- X.509, CMS, and PKCS handling
- Optional OpenSSL or GMP acceleration
- Multiple PHP version release branches
- Composer PSR-4 packaging
Use cases
- Transfer files over SFTP from PHP jobs
- Automate SSH commands without shell binaries
- Parse or validate X.509 certificates in PHP
- Encrypt data where only PHP is available