PHPackages                             inovanti-bank/rsa-validator - 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. inovanti-bank/rsa-validator

ActiveLibrary[Security](/categories/security)

inovanti-bank/rsa-validator
===========================

Package for validation and decryption using RSA public keys (Private Key and Public Key)

v1.0.0(1y ago)11.1k↑88.9%MITPHPPHP ^8.0

Since Dec 11Pushed 1y agoCompare

[ Source](https://github.com/Inovanti-Bank/rsa-validator)[ Packagist](https://packagist.org/packages/inovanti-bank/rsa-validator)[ RSS](/packages/inovanti-bank-rsa-validator/feed)WikiDiscussions production Synced 3w ago

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

RSA Validator
=============

[](#rsa-validator)

[![Latest Stable Version](https://camo.githubusercontent.com/d79f666ebf6c3db90d0a5cfdbd9270890b3ef6c3dc1cae2a7c2884a660a0011c/68747470733a2f2f706f7365722e707567782e6f72672f696e6f76616e74692d62616e6b2f7273612d76616c696461746f722f76)](//packagist.org/packages/inovanti-bank/rsa-validator)[![Total Downloads](https://camo.githubusercontent.com/b47fb4d0ec2f82f3df830aab4f15246943288ee02424b67efe0d8df6ec56af18/68747470733a2f2f706f7365722e707567782e6f72672f696e6f76616e74692d62616e6b2f7273612d76616c696461746f722f646f776e6c6f616473)](//packagist.org/packages/inovanti-bank/rsa-validator)[![License](https://camo.githubusercontent.com/2c1056891aa89b16caf863f8d27f080e25ffdc8e9de4cb550f90364535b1f480/68747470733a2f2f706f7365722e707567782e6f72672f696e6f76616e74692d62616e6b2f7273612d76616c696461746f722f6c6963656e7365)](//packagist.org/packages/inovanti-bank/rsa-validator)

A Laravel ^11 package for validating and decrypting data using RSA public and private keys. This package is designed to simplify secure communication with APIs using client-specific keys.

---

**Features**
------------

[](#features)

- Decrypts and validates Base64-encoded data using public RSA keys.
- Supports configuration of key storage in the database.
- Automatically loads migrations and configuration for Laravel projects.
- Fully compatible with Laravel ^11 and PHP ^8.0+.

---

**Installation**
----------------

[](#installation)

To install the package via Composer, run:

```
composer require inovanti-bank/rsa-validator
```

Configuration
-------------

[](#configuration)

- After installing the package, the configuration and migrations are automatically loaded.
- If you need to customize the configuration file, you can publish it manually using:

```
php artisan vendor:publish --provider="InovantiBank\RSAValidator\Providers\RSAValidatorServiceProvider" --tag="config"
```

- This will publish the config/rsa-validator.php file. The default configuration is as follows:

```
return [
    'table_name' => 'rsa_validator', // Name of the table storing public keys
];
```

How to Use
==========

[](#how-to-use)

Storing Public Keys
-------------------

[](#storing-public-keys)

Ensure you have a table (rsa\_validator by default) to store the public keys. Use the following schema to insert a public key:

```
DB::table('rsa_validator')->insert([
    'client_id' => 'client-unique-id',
    'public_key' => '-----BEGIN PUBLIC KEY-----...-----END PUBLIC KEY-----',
]);
```

Decrypting Data
---------------

[](#decrypting-data)

To decrypt and validate incoming data:

```
use InovantiBank\RSAValidator\Facades\RSAValidator;

try {
    $decryptedData = RSAValidator::decryptData('client-id', $encryptedBase64Data);
    echo $decryptedData;
} catch (\Exception $e) {
    echo 'Error: ' . $e->getMessage();
}
```

Exception Handling
------------------

[](#exception-handling)

The following exceptions may be thrown:

- PublicKeyNotFoundException: Public key for the specified client is not found.
- DecryptionFailedException: The decryption process faile

Testing
-------

[](#testing)

It is highly recommended that you create some tests in your Laravel project to ensure that it works, see some test examples:

```
