tricioandrade / openscrypt
A package for data encryption
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=8.1
- ext-openssl: *
Requires (Dev)
- phpunit/phpunit: ^10.4@dev
This package is auto-updated.
Last update: 2024-11-11 13:35:48 UTC
README
OpensCrypt is a package that aims to integrate scripts Classes or Objects, methods that will use PHP's cryptographic functions to encrypt data.
The class uses the Openssl php library to generate key pairs for asymmetric encryption.
Installation
composer require tricioandrade/openscrypt
How to use generate keys
<?php $instance = new GenerateKeys(); $instance->generate(); // Print or save your keys anywere $instance->getKeys();
Change where you want save your keys
$instance = new GenerateKeys(__DIR__ . '\\');
Get complete keys path or the generated keys:
$instance = new GenerateKeys(__DIR__ . '\\'); $instance->generate(); if ($instance->isPem()){ print_r($instance->getKeysPath()); } else{ print_r($instance->getKeys()); }
Change files name:
$instance->privateKeyFileName = 'MyPrivateKey.pem'; $instance->publicKeyFileName = 'MyPublicKey.pem';
Starting encryption
$cypher = new Cypher('Hello'); print_r( $cypher->setCypherKey(file_get_contents('./MyPrivateKey.pem')) ->getHash() );