teguh02/rsa_php
最新稳定版本:v1.1
Composer 安装命令:
composer require teguh02/rsa_php
包简介
Simple package to handle RSA encryption and decryption algorithm
README 文档
README
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");
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-04