phpseclib
Pure-PHP implementations of SSH2, SFTP, X.509, RSA, AES, and dozens of other cryptographic primitives
Repository Health
Technical Analysis
phpseclib is a pure-PHP cryptography and secure-communications library that has served as the de facto standard for SSH, SFTP, and X.509 handling in the PHP ecosystem since 2012. It implements SSH-2 and SFTP clients, X.509 certificate parsing and generation, an arbitrary-precision integer arithmetic library, and a wide range of symmetric and asymmetric ciphers including RSA, DSA, DH, ECDSA/ECDH (66 curves), Ed25519/Ed449, AES, Blowfish, Twofish, ChaCha20, and Salsa20 — all without requiring PHP’s OpenSSL extension, though it will use OpenSSL when available for speed.
With over 5,500 GitHub stars, 191 contributors, and roughly 10 million monthly Composer downloads, it underpins SSH/SFTP functionality in projects ranging from WordPress plugins to enterprise deployment tooling. The library maintains parallel long-term-support branches (1.0 through the upcoming 4.0) so that legacy PHP 5.3 codebases and modern PHP 8.1+ applications can both depend on a stable, security-audited implementation.
What You Get
- SSH-2 client with exec, shell, port-forwarding, and agent-forwarding support
- SFTP client for uploading, downloading, and managing remote files over SSH
- X.509 certificate, CRL, and CSR parsing and generation (split into dedicated classes in 4.0)
- Asymmetric crypto: RSA (PKCS#1 v2.2), DSA, DH, ECDSA/ECDH across 66 curves, Ed25519/Ed449
- Symmetric ciphers: AES, Rijndael, Blowfish, Twofish, DES/3DES, RC2/RC4, ChaCha20, Salsa20, with GCM and Poly1305 AEAD modes
- An arbitrary-precision BigInteger engine with pluggable math backends (GMP, BCMath, pure-PHP)
- ASN.1 encoding/decoding used internally by the X.509 and public-key modules
Common Use Cases
- Automating SFTP file transfers and remote command execution from PHP deployment scripts
- Parsing and validating X.509 certificates for TLS client verification or internal PKI tooling
- Signing and verifying data with RSA/ECDSA when a hosting environment lacks the OpenSSL extension
- Generating and managing SSH key pairs (RSA, Ed25519, ECDSA) programmatically
Under The Hood
Architecture — phpseclib organizes code under phpseclib/phpseclib3 (with legacy phpseclib1/phpseclib2 namespaces on older LTS branches) into Crypt (symmetric and asymmetric ciphers), Net (SSH2/SFTP protocol clients), File (ASN.1 and X.509 parsing), Math (BigInteger with pluggable engines), Common, and System. Each cipher lives in its own class (e.g. Crypt/AES.php, Crypt/RSA.php) with shared engine-selection logic that transparently falls back between pure-PHP, GMP, and OpenSSL implementations depending on what the host PHP build has available.
Tech Stack — Pure PHP 8.1+ with only two runtime dependencies: paragonie/constant_time_encoding for timing-safe encoding and symfony/polyfill-php82 for forward compatibility. Development tooling includes PHPUnit 13 (via brianium/paratest for parallel test runs), PHP_CodeSniffer, php-parallel-lint, and Vimeo’s Psalm for static analysis — a notably rigorous toolchain for a pure-PHP crypto library.
Code Quality — 67 test files under tests/Unit and tests/Functional cover each crypto primitive and protocol client individually (tests/Unit/Crypt, tests/Unit/Net, tests/Unit/Math, tests/Unit/File), plus a PsalmBaselineTest enforcing static-analysis regressions don’t creep in. A SECURITY.md and Tidelift-coordinated disclosure process reflect the seriousness expected of a crypto library; 191 contributors and 6,275 total commits indicate broad external review over its 14-year history.
API Design — The library favors small, purpose-built classes per algorithm (new RSA(), new AES('gcm')) over one monolithic crypto facade, which keeps usage explicit but requires consulting per-class docs for parameters like cipher mode. The parallel 1.0–4.0 branch strategy with distinct PSR-4 namespaces (\phpseclib3 etc.) lets consumers pin a stable major version without namespace collisions, at the cost of some documentation fragmentation across branches.
Used by 6 apps in this directory
Coolify
Devops · Hosting Control Panel
Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in
EspoCRM
Marketing · Ecommerce · CRM
Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira
LimeSurvey
Forms Surveys
The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.
Pixelfed
Social Media
A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.
Vanguard Backup
Devops
Self-hosted backup automation for Ubuntu and Debian servers with S3 storage, SSH-based file and database backup, and multi-channel notifications.