PHPackages                             phpseclib/phpseclib2\_compat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpseclib/phpseclib2\_compat

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpseclib/phpseclib2\_compat
============================

phpseclib 2.0 polyfill built with phpseclib 3.0

1.0.7(1mo ago)131.9M—0.7%612MITPHPCI failing

Since Dec 19Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/phpseclib/phpseclib2_compat)[ Packagist](https://packagist.org/packages/phpseclib/phpseclib2_compat)[ Docs](https://github.com/phpseclib/phpseclib2_compat)[ RSS](/packages/phpseclib-phpseclib2-compat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (10)Used By (12)

phpseclib2\_compat
==================

[](#phpseclib2_compat)

[![CI Status](https://github.com/phpseclib/phpseclib2_compat/actions/workflows/ci.yml/badge.svg?branch=master&event=push "CI Status")](https://github.com/phpseclib/phpseclib2_compat/actions/workflows/ci.yml?query=branch%3Amaster)

phpseclib 2.0 polyfill built with phpseclib 3.0

Overview
--------

[](#overview)

phpseclib 3.0 breaks backwards compatability with phpseclib 2.0. Most notably, public keys work completely differently. So let's say you wanted to use phpseclib 3.0 whilst some of your other dependencies still use phpseclib 2.0. What would you do in that instance?

That's where phpseclib2\_compat comes into play. Require phpseclib/phpseclib:~3.0 and phpseclib/phpseclib2\_compat:~1.0 and your dependencies will magically start using phpseclib 3.0 even if they don't know it.

Using phpseclib2\_compat will actually bring a few enhancements to your dependencies. For example, while phpseclib 2.0 only supports RSA keys phpseclib2\_compat sports support for ECDSA / DSA / Ed25519 / Ed449 keys.

Consider this code sample:

```
use phpseclib\Crypt\RSA;

$rsa = new RSA;
$rsa->loadKey('ecdsa private key');

$ssh = new SSH2('website.com');
$ssh->login('username', $rsa);
```

That'll work with phpseclib2\_compat, even with an ECDSA private key, whereas in phpseclib 2.0 it would not work.

SSH1 and SCP are not supported but those were likely never frequently used anyway.

Using the old cipher suite
--------------------------

[](#using-the-old-cipher-suite)

phpseclib 3.0 uses a different cipher suite (an expanded one) than 2.0. If this causes you issues you can use the 2.0 ciphersuite by doing this prior to calling `$ssh->login()`:

```
$methods = [
    'crypt' => array_intersect([
        'arcfour256',
        'arcfour128',
        'aes128-ctr',
        'aes192-ctr',
        'aes256-ctr',
        'twofish128-ctr',
        'twofish192-ctr',
        'twofish256-ctr',
        'aes128-cbc',
        'aes192-cbc',
        'aes256-cbc',
        'twofish128-cbc',
        'twofish192-cbc',
        'twofish256-cbc',
        'twofish-cbc',
        'blowfish-ctr',
        'blowfish-cbc',
        '3des-ctr',
        '3des-cbc'
    ], $ssh->getSupportedEncryptionAlgorithms()),
    'mac' => [
        'hmac-sha2-256',
        'hmac-sha1-96',
        'hmac-sha1',
        'hmac-md5-96',
        'hmac-md5'
    ],
    'comp' => ['none']
];

$ssh->setPreferredAlgorithms([
    'kex' => [
        'curve25519-sha256@libssh.org',
        'diffie-hellman-group-exchange-sha256',
        'diffie-hellman-group-exchange-sha1',
        'diffie-hellman-group14-sha1',
        'diffie-hellman-group14-sha256'
    ],
    'hostkey' => [
        'rsa-sha2-256',
        'rsa-sha2-512',
        'ssh-rsa',
        'ssh-dss'
    ],
    'client_to_server' => $methods,
    'server_to_client' => $methods
]);
```

Installation
------------

[](#installation)

With [Composer](https://getcomposer.org/):

```
composer require phpseclib/phpseclib2_compat:~1.0

```

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~239 days

Recently: every ~439 days

Total

9

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1214cf33299ce51f30c9c199cf3b55e8630cc16d5df714c551407088937e9988?d=identicon)[terrafrost](/maintainers/terrafrost)

---

Top Contributors

[![terrafrost](https://avatars.githubusercontent.com/u/214474?v=4)](https://github.com/terrafrost "terrafrost (70 commits)")[![adriano66](https://avatars.githubusercontent.com/u/3438696?v=4)](https://github.com/adriano66 "adriano66 (1 commits)")[![bilogic](https://avatars.githubusercontent.com/u/946010?v=4)](https://github.com/bilogic "bilogic (1 commits)")[![dhedberg](https://avatars.githubusercontent.com/u/279067?v=4)](https://github.com/dhedberg "dhedberg (1 commits)")[![jonlee90](https://avatars.githubusercontent.com/u/17611175?v=4)](https://github.com/jonlee90 "jonlee90 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpseclib-phpseclib2-compat/health.svg)

```
[![Health](https://phpackages.com/badges/phpseclib-phpseclib2-compat/health.svg)](https://phpackages.com/packages/phpseclib-phpseclib2-compat)
```

###  Alternatives

[jenssegers/optimus

Id obfuscation based on Knuth's integer hash method

1.3k4.8M27](/packages/jenssegers-optimus)[phpseclib/mcrypt_compat

PHP 5.x-8.x polyfill for mcrypt extension

28029.7M34](/packages/phpseclib-mcrypt-compat)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[phpseclib/bcmath_compat

PHP 5.x-8.x polyfill for bcmath extension

16720.7M17](/packages/phpseclib-bcmath-compat)[codercat/jwk-to-pem

Convert JWK to PEM format.

1004.5M20](/packages/codercat-jwk-to-pem)[salla/zatca

A helper to generate the QR code and signed it for ZATCA e-invoicing

159416.7k2](/packages/salla-zatca)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
