Skip to content

Commit

Permalink
Made it possible to add additional config to creating files
Browse files Browse the repository at this point in the history
  • Loading branch information
molteber committed Mar 24, 2016
1 parent b91d469 commit b018db7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Crypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,22 @@ public function isFilesCreated()

/**
* @param bool $force
* @param array $config Additional config fields. Will override the defaults
* @throws \Exception
*/
public function createKeys($force = false)
public function createKeys($force = false, $config = [])
{
if (!$this->isFilesCreated() || $force) {
$folder = $this->folder;
$public = $folder . DIRECTORY_SEPARATOR . (!empty($this->name) ? $this->name . "_" : "") . "public.pem";
$private = $folder . DIRECTORY_SEPARATOR . (!empty($this->name) ? $this->name . "_" : "") . "private.pem";

$config = array(
$config = array_merge($config, array(
'digest_alg' => 'sha512',
'private_key_bits' => 4096,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
'encrypt_key' => true
);
));

// Create the private and public key
$res = openssl_pkey_new($config);
Expand Down

0 comments on commit b018db7

Please sign in to comment.