PHPackages                             bravist/pikirasa - 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. [Security](/categories/security)
4. /
5. bravist/pikirasa

ActiveLibrary[Security](/categories/security)

bravist/pikirasa
================

PKI public/private RSA key encryption using the OpenSSL extension

1.0.5(9y ago)0921BSDPHPPHP &gt;=5.4

Since Aug 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/bravist/pikirasa)[ Packagist](https://packagist.org/packages/bravist/pikirasa)[ Docs](https://github.com/bravist/pikirasa)[ RSS](/packages/bravist-pikirasa/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (7)Used By (1)

Pikirasa
========

[](#pikirasa)

1.0.5 release
-------------

[](#105-release)

Supports encrypted string more than 117. see [openssl\_private\_encrypt can encrypt a maximum of 117 chars at one time](http://php.net/manual/zh/function.openssl-private-encrypt.php)

Easy PKI public/private RSA key encryption using the OpenSSL extension.

What's up with the name?
------------------------

[](#whats-up-with-the-name)

Pikirasa is just "PKI RSA" with a few exta vowels thrown in. Also, I created this project late on a Friday night, so I just couldn't bring myself to name it anything serious.

What is this for?
-----------------

[](#what-is-this-for)

Pikirasa is very lightweight wrapper around PHP's OpenSSL extension for encrypting and decrypting data with a known public/private key pair. It requires that you have the [OpenSSL extension](http://php.net/openssl) installed, and that your certificates have already been generated.

*Pikirasa is not a general purpose or all-encompassing encryption library*. If you need more encryption options, maximum system compatability, or if you need to generate RSA keys programatically, take a look at [phpseclib](https://github.com/phpseclib/phpseclib).

Example Usage
-------------

[](#example-usage)

All your need is the full path to your public and/or private key files:

```
$rsa = new Pikirasa\RSA('path/to/public.pem', 'path/to/private.pem');

$data = 'abc123';
$encrypted = $rsa->encrypt($data);
$decrypted = $rsa->decrypt($encrypted);
var_dump($decrypted); // 'abc123'
```

Under the hood, Pikirasa will make these paths file streams, and you may use any file stream directly instead :

```
$rsa = new Pikirasa\RSA('file:///absolute/path/to/public.pem', 'file://relative/path/to/private.pem');

$data = 'abc123';
$encrypted = $rsa->encrypt($data);
$decrypted = $rsa->decrypt($encrypted);
var_dump($decrypted); // 'abc123'
```

You can also use the string contents of your public and private keys :

```
$publicKey = '
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7o9A47JuO3wgZ/lbOIOs
Xc6cVSiCMsrglvORM/54StFRvcrxMi7OjXD6FX5fQpUOQYZfIOFZZMs6kmNXk8xO
hgTmdMJcBWolQ85acfAdWpTpCW29YMvXNARUDb8uJKAApsISnttyCnbvp7zYMdQm
HiTG/+bYaegSXzV3YN+Ej+ZcocubUpLp8Rpzz+xmXep3BrjBycAE9z2IrrV2rlwg
TTxU/B8xmvMsToBQpAbe+Cv130tEHsyW4UL9KZY1M9R+UHFPPmORjBKxSZvjJ1mS
UbUYN6PmMry35wCaFCfQoyTDUxBfxTGYqjaveQv4sxx0uvoiLXHt9cAm5Q8KJ+8d
FwIDAQAB
-----END PUBLIC KEY-----
';

$privateKey = '
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA7o9A47JuO3wgZ/lbOIOsXc6cVSiCMsrglvORM/54StFRvcrx
Mi7OjXD6FX5fQpUOQYZfIOFZZMs6kmNXk8xOhgTmdMJcBWolQ85acfAdWpTpCW29
YMvXNARUDb8uJKAApsISnttyCnbvp7zYMdQmHiTG/+bYaegSXzV3YN+Ej+Zcocub
UpLp8Rpzz+xmXep3BrjBycAE9z2IrrV2rlwgTTxU/B8xmvMsToBQpAbe+Cv130tE
HsyW4UL9KZY1M9R+UHFPPmORjBKxSZvjJ1mSUbUYN6PmMry35wCaFCfQoyTDUxBf
xTGYqjaveQv4sxx0uvoiLXHt9cAm5Q8KJ+8dFwIDAQABAoIBAHkWS3iHy/3zjjtY
TV4NL8NZqO5splGDuqXEMbKzenl3b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oGZrU7JzCxuyoeA/4z36UN5WXmeS3bqh6SinrPQKt7rMkK1NQYcDUijPBMt0afO+
LH0HIC1HAtS6Wztd2Taoqwe5Xm75YW0elo4OEqiAfubAC85Ec4zfxw==
-----END RSA PRIVATE KEY-----
';

$rsa = new Pikirasa\RSA($publicKey, $privateKey);

$data = 'abc123';
$encrypted = $rsa->encrypt($data);
$decrypted = $rsa->decrypt($encrypted);
var_dump($decrypted); // 'abc123'
```

### Using Certificates with a Passphrase

[](#using-certificates-with-a-passphrase)

The `Pikirasa\RSA` class accepts an optional 3rd parameter if your private key is protected with a password.

```
$rsa = new Pikirasa\RSA($publicKey, $privateKey, 'certificate_password');

$data = 'abc123';
$encrypted = $rsa->encrypt($data);
$decrypted = $rsa->decrypt($encrypted);
var_dump($decrypted); // 'abc123'
```

### Working with base64-encoded strings

[](#working-with-base64-encoded-strings)

A common pattern if you want to deal with plain strings rather than binary data is to encode encryped data with base64. If you need to do that, both `encrypt`and `decrypt` have a base64 counterpart you can use :

```
$rsa = new Pikirasa\RSA($publicKey, $privateKey);

$data = 'abc123';
$encrypted = $rsa->base64Encrypt($data);
$decrypted = $rsa->base64Decrypt($encrypted);
var_dump($decrypted); // 'abc123'
```

encrypt a maximum of 117 chars at one time

```
$rsa = new Pikirasa\RSA($publicKey, $privateKey);

$data = 'abc123';
$encrypted = $rsa->base64EncryptForLongChars($data);
$decrypted = $rsa->base64DecryptForLongChars($encrypted); // this is testing...
var_dump($decrypted); // 'abc123'
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 82.4% 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 ~154 days

Recently: every ~192 days

Total

6

Last Release

3571d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/195282e1beeb9475b56cbf1b7fcb9c28f9e3232834181d3e95b3f150e3be4b5a?d=identicon)[bravist](/maintainers/bravist)

---

Top Contributors

[![vlucas](https://avatars.githubusercontent.com/u/187?v=4)](https://github.com/vlucas "vlucas (14 commits)")[![greg0ire](https://avatars.githubusercontent.com/u/657779?v=4)](https://github.com/greg0ire "greg0ire (3 commits)")

---

Tags

cryptographyencryptionrsaPrivate Keypublic keyopensslcryptpki

### Embed Badge

![Health badge](/badges/bravist-pikirasa/health.svg)

```
[![Health](https://phpackages.com/badges/bravist-pikirasa/health.svg)](https://phpackages.com/packages/bravist-pikirasa)
```

###  Alternatives

[vlucas/pikirasa

PKI public/private RSA key encryption using the OpenSSL extension

104104.1k1](/packages/vlucas-pikirasa)[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k455.2M1.5k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k170.7M239](/packages/defuse-php-encryption)[miladrahimi/phpcrypt

Encryption, decryption, and hashing tools for PHP projects

3074.2k2](/packages/miladrahimi-phpcrypt)[asymmetricrypt/asymmetricrypt

A simple PHP public key cryptography library

104.3k](/packages/asymmetricrypt-asymmetricrypt)

PHPackages © 2026

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