Skip to content

Simple package to handle RSA encryption and decryption algorithm

Notifications You must be signed in to change notification settings

teguh02/rsa_php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package Information

Simple package to handle RSA encryption and decryption algorithm

This PHP library are couples from this php library https://github.com/teguh02/rsa_js

Installation

If you want to install this library you can install with this command composer require teguh02/rsa_php

Usage

<?php

// import autoload
require_once __DIR__ . '/../vendor/autoload.php';

// Import the RSA module
use Teguh02\RsaPhp\RSA;

// Define p and q
const P = 61;
const Q = 53;

// Generate the RSA public and private keys
$keys = RSA::generateKeys(P, Q);

// Print the public and private keys
echo "Public key: (" . $keys["public"][0] . ", " . $keys["public"][1] . ")\n";
echo "Private key: (" . $keys["private"][0] . ", " . $keys["private"][1] . ")\n";

// Define the message to be encrypted
$message = "I LOVE YOU";

// Encrypt the message using the public key
$encrypted = RSA::encrypt($message, $keys);
print("Encrypted message: " . join(",", $encrypted) . "\n");

// Decrypt the message using the private key
// $decrypted = RSA::decrypt($encrypted, $keys);
$decrypted = RSA::decrypt('286,2774,83,913,1781,155,2774,206,913,2509', $keys);
print("Decrypted message: " . $decrypted . "\n");

About

Simple package to handle RSA encryption and decryption algorithm

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages