From 1bd83cd1a245460de444d7d5a08785e49dc57209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Mon, 18 Sep 2023 11:22:13 +0200 Subject: [PATCH] openssl gen rsa --- app/public/css/custom.css | 2 +- app/public/index.php | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/public/css/custom.css b/app/public/css/custom.css index 7ebd0ce..1722222 100644 --- a/app/public/css/custom.css +++ b/app/public/css/custom.css @@ -1,6 +1,6 @@ :root { - --form-element-spacing-vertical: .15rem; + --form-element-spacing-vertical: .09rem; --form-element-spacing-horizontal: 1rem; --border-radius: .10rem; --line-height: 1.3; diff --git a/app/public/index.php b/app/public/index.php index c116672..68fb2a9 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -23,6 +23,7 @@ $buttons = [ 'prettyjson' => 'Pretty JSON', 'prettyxml' => 'Pretty XML', 'serializedtojson' => 'PHP Serialized to JSON', + 'openssl_genrsa' => 'OpenSSL genrsa', ]; $str = $result = $_POST['str'] ?? $_GET['str'] ?? ''; @@ -34,7 +35,7 @@ $jsonEncodeOptions = JSON_PRETTY_PRINT | JSON_PRESERVE_ZERO_FRACTION | JSON_UNES if ($action == 'reset') { http_response_code(302); header("Location: /"); - die(); + exit; } elseif ($action == 'urlencode') { $result = urlencode($str)?: $str; @@ -129,6 +130,20 @@ if ($action == 'reset') { } $help = 'https://www.php.net/serialize'; +} elseif ($action == 'openssl_genrsa') { + $passphrase = strlen($str) > 0 ? hash('sha256', $str) : bin2hex(openssl_random_pseudo_bytes(32)); + $options = ['private_key_bits' => 2048, 'encrypt_key' => true, 'encrypt_key_cipher' => OPENSSL_CIPHER_AES_128_CBC]; + $key = openssl_pkey_new($options); + openssl_pkey_export($key, $pkey, $passphrase); + + $result = "Passphrase: " . $passphrase . "\n\n" . $pkey . "\n" . openssl_pkey_get_details($key)['key']; + + $help = 'https://www.php.net/openssl_pkey_new'; + +} else { + $str = ''; + $action = ''; + $help = 'https://www.php.net/'; } if ($plain) { @@ -142,7 +157,7 @@ if ($plain) { - Decode/Encode everything + Decode/Encode/Hash/Pretty/etc @@ -165,7 +180,7 @@ if ($plain) { Reset Help
-

Contact me via email or twitter. Made with pure PHP and Pico.css. Source code. s

+

contact · source code · s