Skip to content

Commit

Permalink
adding custom filter (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic authored May 21, 2024
1 parent a8a716e commit 05949f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).

## [1.3.6]

### Fixed
- Encrypted data now supports filters to provide custom keys.

## [1.3.5]

### Fixed
Expand Down Expand Up @@ -136,6 +141,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

- Initial production release.

[1.3.6]: https://github.com/infinum/eightshift-forms-utils/compare/1.3.5...1.3.6
[1.3.5]: https://github.com/infinum/eightshift-forms-utils/compare/1.3.4...1.3.5
[1.3.4]: https://github.com/infinum/eightshift-forms-utils/compare/1.3.3...1.3.4
[1.3.3]: https://github.com/infinum/eightshift-forms-utils/compare/1.3.2...1.3.3
Expand Down
8 changes: 6 additions & 2 deletions src/Helpers/UtilsEncryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ class UtilsEncryption
*/
public static function encryptor(string $value, string $action = 'encrypt')
{
$filterNameSecretKey = UtilsHooksHelper::getFilterName(['encryption', 'secretKey']);
$secretKey = \apply_filters($filterNameSecretKey, \wp_salt()); // user define private key.

$filterNameSecretIv = UtilsHooksHelper::getFilterName(['encryption', 'secretIvKey']);
$secretIv = \apply_filters($filterNameSecretIv, \wp_salt('SECURE_AUTH_KEY')); // user define secret key.

$encryptMethod = "AES-256-CBC";
$secretKey = \wp_salt(); // user define private key.
$secretIv = \wp_salt('SECURE_AUTH_KEY'); // user define secret key.
$key = \hash('sha256', $secretKey);
$iv = \substr(\hash('sha256', $secretIv), 0, 16); // sha256 is hash_hmac_algo.

Expand Down

0 comments on commit 05949f4

Please sign in to comment.