Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\Security\Encryption;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Enterprise Application Encryption Service Contract.
13 *
14 * Provides authenticated symmetric encryption and decryption for sensitive data,
15 * such as SMTP credentials, third-party API secrets, and access tokens.
16 *
17 * @package App\Core\Security\Encryption
18 */
19interface EncryptionServiceInterface
20{
21    /**
22     * Encrypts plaintext string using authenticated encryption (AES-256-GCM).
23     *
24     * @param string $plaintext Raw secret text to encrypt.
25     * @return string Encrypted payload formatted as versioned serialized string.
26     */
27    public function encrypt(string $plaintext): string;
28
29    /**
30     * Decrypts encrypted payload back to original plaintext string.
31     *
32     * @param string $payload Serialized encrypted payload.
33     * @return string Original plaintext secret.
34     */
35    public function decrypt(string $payload): string;
36
37    /**
38     * Checks if given string is an encrypted payload format.
39     *
40     * @param string $value String to test.
41     * @return bool True if formatted as encrypted payload.
42     */
43    public function isEncrypted(string $value): bool;
44
45    /**
46     * Re-encrypts payload using active key version if payload was encrypted with an older key.
47     *
48     * @param string $payload Serialized encrypted payload.
49     * @return string Re-encrypted payload with current active key.
50     */
51    public function reEncrypt(string $payload): string;
52}