mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 22:34:50 +03:00
EncryptionHelper
This commit is contained in:
parent
c8a9d92a7b
commit
6c1ae655cd
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Administrator
|
||||||
|
* @subpackage com_oauthserver
|
||||||
|
*
|
||||||
|
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||||
|
* @license MIT; see LICENSE.txt
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace Webmasterskaya\Component\OauthServer\Administrator\Helper;
|
||||||
|
|
||||||
|
class EncryptionHelper
|
||||||
|
{
|
||||||
|
public static function generatingKeys(string $alg = 'sha512', int $length = 4096, int $type = OPENSSL_KEYTYPE_RSA, ?string $passphrase = null): array
|
||||||
|
{
|
||||||
|
$config = [
|
||||||
|
"digest_alg" => $alg,
|
||||||
|
"private_key_bits" => $length,
|
||||||
|
"private_key_type" => $type,
|
||||||
|
"encrypt_key" => !empty($passphrase)
|
||||||
|
];
|
||||||
|
|
||||||
|
$private_key = '';
|
||||||
|
$key = openssl_pkey_new($config);
|
||||||
|
|
||||||
|
openssl_pkey_export($key, $private_key, $passphrase);
|
||||||
|
|
||||||
|
$public_key = openssl_pkey_get_details($key);
|
||||||
|
|
||||||
|
return [$private_key, $public_key['key']];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user