Skip to content

Conversation

@MayMeow
Copy link
Owner

@MayMeow MayMeow commented Jun 4, 2025

closes #29

This pull request add better compatibilty with javascript encrypted data.

@MayMeow MayMeow changed the title Add legacy support for encryption and decryption methods in AESC Add legacy support for encryption and decryption methods in AES Jun 4, 2025
@MayMeow MayMeow changed the title Add legacy support for encryption and decryption methods in AES Add legacy support for encryption and decryption methods in AES CyriptoService provider Jun 4, 2025
@MayMeow MayMeow requested a review from Copilot June 4, 2025 09:56

This comment was marked as outdated.

@MayMeow MayMeow requested a review from Copilot June 4, 2025 10:02

This comment was marked as outdated.

@MayMeow MayMeow requested a review from Copilot June 4, 2025 10:50

This comment was marked as outdated.

@MayMeow MayMeow requested a review from Copilot June 4, 2025 11:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a legacy flag to the AES CryptoService provider to support JavaScript–compatible payload formats.

  • Extended encrypt and decrypt methods with a bool $legacy parameter to switch IV/TAG ordering.
  • Factored payload construction into buildPayload and parsing into parsePayload.
  • Updated tests to verify both default and legacy encryption/decryption flows.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/AESCryptoServiceProvider.php Added legacy parameter, buildPayload/parsePayload methods, and updated docblocks
tests/AESCryptoServiceProviderTest.php Added legacy-encryption test cases and decrypt(..., legacy: true) assertion
Comments suppressed due to low confidence (3)

src/AESCryptoServiceProvider.php:161

  • [nitpick] The single-letter variable $c is not descriptive. Rename it to $cipherText for clarity.
$c = base64_decode($encryptedData);

tests/AESCryptoServiceProviderTest.php:19

  • [nitpick] Add spaces around the = operator to match coding style ($encryptedText = ...).
$encryptedText= $csp->encrypt($plainText, legacy: true);

src/AESCryptoServiceProvider.php:152

  • [nitpick] Merge the $legacy param description onto the same line (e.g. @param bool $legacy True = IV-TAG-EncryptedData; false = IV-EncryptedData-TAG).
@param bool $legacy

@MayMeow MayMeow merged commit 0b8816d into main Jun 4, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make AES export format compatible with JavaScript Web Crypto (TAG as last element)

2 participants