Update: 2026-06-16 22:44:11
This commit is contained in:
47
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/generate_keys.php
Executable file
47
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/generate_keys.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// File: generate_keys.php
|
||||
// الوظيفة: إنشاء زوج المفاتيح (العام والخاص) لمرة واحدة فقط
|
||||
|
||||
// إعدادات لتوليد المفتاح
|
||||
$config = [
|
||||
"digest_alg" => "sha256",
|
||||
"private_key_bits" => 1024,
|
||||
"private_key_type" => OPENSSL_KEYTYPE_RSA,
|
||||
];
|
||||
|
||||
// إنشاء زوج المفاتيح
|
||||
$res = openssl_pkey_new($config);
|
||||
|
||||
if (!$res) {
|
||||
die('Failed to generate new private key. Error: ' . openssl_error_string());
|
||||
}
|
||||
|
||||
// استخراج المفتاح الخاص
|
||||
openssl_pkey_export($res, $private_key);
|
||||
|
||||
// استخراج المفتاح العام
|
||||
$public_key_details = openssl_pkey_get_details($res);
|
||||
$public_key = $public_key_details["key"];
|
||||
|
||||
// حفظ المفاتيح في ملفات
|
||||
file_put_contents('private_key.pem', $private_key);
|
||||
file_put_contents('public_key.pem', $public_key);
|
||||
|
||||
echo "<h1>Keys Generated Successfully!</h1>";
|
||||
echo "<h2>Private Key (saved to private_key.pem):</h2>";
|
||||
echo "<pre>" . htmlspecialchars($private_key) . "</pre>";
|
||||
echo "<h2>Public Key (saved to public_key.pem):</h2>";
|
||||
echo "<pre>" . htmlspecialchars($public_key) . "</pre>";
|
||||
|
||||
// --- تحضير المفتاح العام لعملية التفعيل ---
|
||||
// إزالة الهيدر والفوتر والأسطر الجديدة كما هو مطلوب
|
||||
$formatted_public_key = str_replace("-----BEGIN PUBLIC KEY-----", "", $public_key);
|
||||
$formatted_public_key = str_replace("-----END PUBLIC KEY-----", "", $formatted_public_key);
|
||||
$formatted_public_key = preg_replace("/\s+/", "", $formatted_public_key);
|
||||
|
||||
|
||||
echo "<h2>Formatted Public Key (for Terminal Activation):</h2>";
|
||||
echo "<p><strong>انسخ هذا المفتاح لاستخدامه في خطوة تفعيل الجهاز (activate_terminal.php)</strong></p>";
|
||||
echo "<textarea rows='5' cols='80' readonly>" . htmlspecialchars($formatted_public_key) . "</textarea>";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user