phpseclib

Pure-PHP implementations of SSH2, SFTP, X.509, RSA, AES, and dozens of other cryptographic primitives

Library
Composer
v4.0.1
5,593 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
93 /100 Excellent
Development Activity 96
Maintenance 96
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 88
Code Quality 90
Innovation 82
Learning Curve 70

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

PHP
81%
Apache 2.0

Coolify

Devops · Hosting Control Panel

62,328

Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in

View details
92
Repo Health
86
Technical
70
Dependency
Built with
PHP 81%
Blade 16%
Updated 6 days ago
PHP
66%
AGPL 3.0

EspoCRM

CRM · Ecommerce · Marketing

3,417

Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.

View details
96
Repo Health
72
Technical
63
Dependency
Built with
PHP 66%
JavaScript 23%
Updated 1 weeks ago
PHP
48%
AGPL 3.0

Leantime

Collaboration · Productivity · Project Management

11,672

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
65
Dependency
Built with
PHP 48%
CSS 20%
Blade 17%
Updated 1 weeks ago
JavaScript
43%
Other

LimeSurvey

Forms Surveys

3,736

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
63
Dependency
Built with
JavaScript 43%
PHP 35%
CSS 12%
Updated 6 days ago
PHP
69%
AGPL 3.0

Pixelfed

Social Media

7,105

A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.

View details
91
Repo Health
68
Technical
65
Dependency
Built with
PHP 69%
Vue 22%
Updated 6 days ago
PHP
63%
AGPL 3.0

Vanguard Backup

Devops

37

Self-hosted backup automation for Ubuntu and Debian servers with S3 storage, SSH-based file and database backup, and multi-channel notifications.

View details
34
Repo Health
80
Technical
69
Dependency
Built with
PHP 63%
Blade 36%
Updated 10 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers