PHPackages                             togos/rsa-util - 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. togos/rsa-util

ActiveLibrary[Security](/categories/security)

togos/rsa-util
==============

Library for generating and verifying RSA signatures

0.1.0(10y ago)0256MITPHPPHP &gt;=5.2

Since Nov 13Pushed 9y agoCompare

[ Source](https://github.com/TOGoS/PHPRSAUtil)[ Packagist](https://packagist.org/packages/togos/rsa-util)[ RSS](/packages/togos-rsa-util/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c11c6aa67ad3073eddf44854b3fd5b59a68ae91cf190151f4e8cf07c94c1da66/68747470733a2f2f7472617669732d63692e6f72672f544f476f532f5048505253415574696c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/TOGoS/PHPRSAUtil)

PHP RSA Util
============

[](#php-rsa-util)

Utilities for generating and verifying signatures and converting between various key formats.

Primary operations revolve around `TOGoS_RSAUtil_Signature`objects, which represent the signing of a specific piece of data with a specific key. A Signature indicates the key and data (either inline or by a hash URI), the algorithm used to calculate the signature, and the signature data itself.

See  for my personal collection of information about key formats.

Usage example
-------------

[](#usage-example)

```
/*
 * Assuming $dataStore is an object that the guy verifying also has
 * access to
 */

$privateKey = file_get_contents('private-key.der'); // Will work with 'pem' files, too.
$publicKey  = file_get_contents('public-key.der');
$payload = "Hello!";

$dataStore->store($payload);
$dataStore->store($publicKey);

$publicKeyUri = "urn:sha1:".TOGoS_Base32::encode(hash('sha1',$publicKey,true));
$sig = TOGoS_RSAUtil::sign($payload, $privateKey, OPENSSL_ALGO_SHA1);

$sigCodec = new TOGoS_RSAUtil_XKRTSignatureCodec();
$sigBlob = $sigCodec->encode($sig);
```

Send `$sigBlob` to someone, and they can...

```
/*
 * Assuming $dataStore and $sigBlob are input variables
 * Using XKRT codec, the public key and payload data are referenced by
 * but not contained in the signature.  We fetch them from $dataStore.
 */

$sigCodec = new TOGoS_RSAUtil_XKRTSignatureCodec();
$sig = $sigCodec->decode($sigBlob);
TOGoS_RSAUtil::verify($sig, $dataStore);
echo "Signature was valid!  Here's the data!\n";
echo (string)$dataStore->getBlob($sig->getPayloadUri());
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3886d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/57142?v=4)[Dan Stevens](/maintainers/TOGoS)[@TOGoS](https://github.com/TOGoS)

---

Top Contributors

[![TOGoS](https://avatars.githubusercontent.com/u/57142?v=4)](https://github.com/TOGoS "TOGoS (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/togos-rsa-util/health.svg)

```
[![Health](https://phpackages.com/badges/togos-rsa-util/health.svg)](https://phpackages.com/packages/togos-rsa-util)
```

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.7M143](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24820.0k38](/packages/paragonie-ecc)

PHPackages © 2026

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