Skip to content

Commit

Permalink
extract key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 3, 2017
1 parent f6e8e6c commit 656fd4c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Encrypter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public static function supported($key, $cipher)
($cipher === 'AES-256-CBC' && $length === 32);
}

/**
* Create a new encryption key for the given cipher.
*
* @param string $cipher
* @return string
*/
public static function generateKey($cipher)
{
return random_bytes($cipher == 'AES-128-CBC' ? 16 : 32);
}

/**
* Encrypt the given value.
*
Expand Down

0 comments on commit 656fd4c

Please sign in to comment.