diff --git a/Encrypter.php b/Encrypter.php index 05c15e9..21f256d 100755 --- a/Encrypter.php +++ b/Encrypter.php @@ -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. *