openssl gen rsa
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Sergio Álvarez 2023-09-18 11:22:13 +02:00
parent 4857ede0e5
commit 1bd83cd1a2
No known key found for this signature in database
GPG Key ID: 622780889DFDBDA5
2 changed files with 19 additions and 4 deletions

View File

@ -1,6 +1,6 @@
:root { :root {
--form-element-spacing-vertical: .15rem; --form-element-spacing-vertical: .09rem;
--form-element-spacing-horizontal: 1rem; --form-element-spacing-horizontal: 1rem;
--border-radius: .10rem; --border-radius: .10rem;
--line-height: 1.3; --line-height: 1.3;

View File

@ -23,6 +23,7 @@ $buttons = [
'prettyjson' => 'Pretty JSON', 'prettyjson' => 'Pretty JSON',
'prettyxml' => 'Pretty XML', 'prettyxml' => 'Pretty XML',
'serializedtojson' => 'PHP Serialized to JSON', 'serializedtojson' => 'PHP Serialized to JSON',
'openssl_genrsa' => 'OpenSSL genrsa',
]; ];
$str = $result = $_POST['str'] ?? $_GET['str'] ?? ''; $str = $result = $_POST['str'] ?? $_GET['str'] ?? '';
@ -34,7 +35,7 @@ $jsonEncodeOptions = JSON_PRETTY_PRINT | JSON_PRESERVE_ZERO_FRACTION | JSON_UNES
if ($action == 'reset') { if ($action == 'reset') {
http_response_code(302); http_response_code(302);
header("Location: /"); header("Location: /");
die(); exit;
} elseif ($action == 'urlencode') { } elseif ($action == 'urlencode') {
$result = urlencode($str)?: $str; $result = urlencode($str)?: $str;
@ -129,6 +130,20 @@ if ($action == 'reset') {
} }
$help = 'https://www.php.net/serialize'; $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) { if ($plain) {
@ -142,7 +157,7 @@ if ($plain) {
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Decode/Encode everything</title> <title>Decode/Encode/Hash/Pretty/etc</title>
<meta name="author" content="Sergio Álvarez <correo@sergio.am>"> <meta name="author" content="Sergio Álvarez <correo@sergio.am>">
<meta name="description" content="Encode and Decode strings from/to URL, Base64, HTML entities, UU, Qprint, hash, hex and more." /> <meta name="description" content="Encode and Decode strings from/to URL, Base64, HTML entities, UU, Qprint, hash, hex and more." />
@ -165,7 +180,7 @@ if ($plain) {
<a href="/" role="button" class="secondary">Reset</a> <a href="/" role="button" class="secondary">Reset</a>
<a href="<?=$help?>" role="button" class="secondary">Help</a> <a href="<?=$help?>" role="button" class="secondary">Help</a>
<hr /> <hr />
<p><small>Contact me via <a href="mailto:correo@sergio.am">email</a> or <a href="https://twitter.com/xergio">twitter</a>. Made with pure <a href="https://php.net/">PHP</a> and <a href="https://picocss.com/"><strong>Pico</strong>.css</a>. <a href="https://sergio.am/code/dencode.xrg.es">Source code</a>. <?php printf("%.6f", (microtime(true) - $start_time)); ?>s</small></p> <p><small><a href="mailto:dencode@sergio.am">contact</a> · <a href="https://sergio.am/code/dencode.xrg.es">source code</a> · <?php printf("%.6f", (microtime(true) - $start_time)); ?>s</small></p>
</div> </div>
<div> <div>