Skip to content

Commit

Permalink
Merge pull request #6 from martinusso/refactor
Browse files Browse the repository at this point in the history
Refactor IV
  • Loading branch information
martinusso authored Oct 26, 2017
2 parents df45736 + 62eaaa5 commit 69101f2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/OpenCrypt/OpenCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ public function __construct(
) {
$this->secretKey = hash('sha256', $secretKey);

if (empty($iv)) {
$iv = self::generateIV();
}
$this->iv = $iv;
$this->iv = $iv ?: self::generateIV();
}

public function encrypt($value) {
public function encrypt(string $value) {
$output = openssl_encrypt(
$value,
self::CIPHER_METHOD,
Expand All @@ -51,7 +48,7 @@ public function encrypt($value) {
return base64_encode($output);
}

public function decrypt($value) {
public function decrypt(string $value) {
return openssl_decrypt(
base64_decode($value),
self::CIPHER_METHOD,
Expand Down

0 comments on commit 69101f2

Please sign in to comment.