File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,20 @@ class Encryption
5353 */
5454 protected $ key ;
5555
56+ /**
57+ * Whether to fall back to previous keys when decryption fails.
58+ *
59+ * @var bool
60+ */
61+ protected bool $ previousKeysFallbackEnabled = false ;
62+
63+ /**
64+ * List of previous keys for fallback decryption.
65+ *
66+ * @var string[]
67+ */
68+ protected array $ previousKeys = [];
69+
5670 /**
5771 * The derived HMAC key
5872 *
@@ -92,6 +106,8 @@ public function __construct(?EncryptionConfig $config = null)
92106 $ config ??= new EncryptionConfig ();
93107
94108 $ this ->key = $ config ->key ;
109+ $ this ->previousKeysFallbackEnabled = $ config ->previousKeysFallbackEnabled ;
110+ $ this ->previousKeys = $ config ->previousKeys ;
95111 $ this ->driver = $ config ->driver ;
96112 $ this ->digest = $ config ->digest ?? 'SHA512 ' ;
97113
@@ -117,6 +133,8 @@ public function initialize(?EncryptionConfig $config = null)
117133 {
118134 if ($ config instanceof EncryptionConfig) {
119135 $ this ->key = $ config ->key ;
136+ $ this ->previousKeysFallbackEnabled = $ config ->previousKeysFallbackEnabled ?? false ;
137+ $ this ->previousKeys = $ config ->previousKeys ?? [];
120138 $ this ->driver = $ config ->driver ;
121139 $ this ->digest = $ config ->digest ?? 'SHA512 ' ;
122140 }
You can’t perform that action at this time.
0 commit comments