Skip to content

Commit

Permalink
Added support for PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsonjohn committed Jan 26, 2023
1 parent e0864e7 commit e02e834
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 50 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities

## [2.0.0] - 2023.01.26

### Added

- Added support for PHP 8.

## [1.0.1] - 2020.11.15

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This project is open source and available under the [MIT License](LICENSE).

## Requirements

* PHP >= 7.1.0
* PHP `^8.0`
* OpenSSL PHP extension
* JSON PHP extension

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"preferred-install": "dist"
},
"require": {
"php": ">=7.1.0",
"php": "^8.0",
"ext-openssl": "*",
"ext-json": "*"
},
Expand Down
7 changes: 0 additions & 7 deletions src/DecryptException.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php

/**
* @package encryptor
* @link https://github.com/bayfrontmedia/encryptor
* @author John Robinson <[email protected]>
* @copyright 2020 Bayfront Media
*/

namespace Bayfront\Encryptor;

use Exception;
Expand Down
7 changes: 0 additions & 7 deletions src/EncryptException.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php

/**
* @package encryptor
* @link https://github.com/bayfrontmedia/encryptor
* @author John Robinson <[email protected]>
* @copyright 2020 Bayfront Media
*/

namespace Bayfront\Encryptor;

use Exception;
Expand Down
21 changes: 7 additions & 14 deletions src/Encryptor.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<?php

/**
* @package encryptor
* @link https://github.com/bayfrontmedia/encryptor
* @author John Robinson <[email protected]>
* @copyright 2020 Bayfront Media
*/

namespace Bayfront\Encryptor;

class Encryptor
{

protected $key;
protected $cipher;
protected string $key;
protected string $cipher;

/**
* Encrypt constructor.
Expand Down Expand Up @@ -48,12 +41,12 @@ public function __construct(string $key, string $cipher = 'AES-256-CBC')
* @throws EncryptException
*/

protected function _createIv()
protected function _createIv(): string
{

$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher));

if (false === $iv) {
if (!$iv) {
throw new EncryptException('Unable to create Initialization Vector');
}

Expand Down Expand Up @@ -91,7 +84,7 @@ public function getCipher(): string
* @return string
*/

protected function _createHash(string $iv, $value): string
protected function _createHash(string $iv, mixed $value): string
{
return hash_hmac('sha256', $iv . $value, $this->key);
}
Expand All @@ -107,7 +100,7 @@ protected function _createHash(string $iv, $value): string
* @throws EncryptException
*/

public function encrypt($value, bool $serialize = true): string
public function encrypt(mixed $value, bool $serialize = true): string
{

if (true === $serialize) {
Expand Down Expand Up @@ -174,7 +167,7 @@ public function encryptString(string $value): string
* @throws DecryptException
*/

public function decrypt(string $data, bool $unserialize = true)
public function decrypt(string $data, bool $unserialize = true): mixed
{

$data = json_decode(base64_decode($data), true);
Expand Down
7 changes: 0 additions & 7 deletions src/InvalidCipherException.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php

/**
* @package encryptor
* @link https://github.com/bayfrontmedia/encryptor
* @author John Robinson <[email protected]>
* @copyright 2020 Bayfront Media
*/

namespace Bayfront\Encryptor;

use Exception;
Expand Down
13 changes: 0 additions & 13 deletions workflows/add-new-issue-to-project.yml

This file was deleted.

0 comments on commit e02e834

Please sign in to comment.