Skip to content

Align PHP Randflake parity with original implementation#1

Merged
Adambean merged 3 commits into
Adambean:mainfrom
lemon-mint:main
May 27, 2026
Merged

Align PHP Randflake parity with original implementation#1
Adambean merged 3 commits into
Adambean:mainfrom
lemon-mint:main

Conversation

@lemon-mint
Copy link
Copy Markdown
Contributor

Align PHP Randflake parity with original implementation

Summary

Align the PHP implementation with the original Go/Python/TypeScript Randflake behavior.

Changes

  • Use little-endian SPARX-64 packing/unpacking to match the original implementation.
  • Replace RFC4648 byte-stream Base32Hex with Randflake’s mathematical base32hex conversion.
  • Remove the unused Paragon ConstantTime Base32Hex dependency.
  • Preserve secret bytes exactly instead of trimming them.
  • Add upstream official test vectors and verify encryption, encoding, decoding, decryption, and
    inspect output.

Verification

  • Used the official Randflake test vectors from the upstream Go implementation.
  • phpunit
  • phpstan analyse
  • php-cs-fixer --dry-run
  • composer validate --strict

Use the upstream official test vectors to verify encrypted IDs, base32hex strings, and inspect output against the Go implementation. Switch SPARX-64 packing to little-endian and replace RFC4648 byte Base32Hex with Randflake's mathematical base32hex conversion.
@Adambean Adambean self-assigned this May 27, 2026
Adambean added 2 commits May 27, 2026 20:18
- Add constants section header.
- Add comment to B32HEX_CHARS constant.
- Add `@throws` documentation to `decodeBase32HexToNumericString()`.
Copy link
Copy Markdown
Owner

@Adambean Adambean left a comment

Choose a reason for hiding this comment

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

Thank you kindly for reviewing this library. Looks like I was using big endian numbers instead of little endian, my fault for using Windows calculator for my bin/dec/hex conversions. Also very cool to reduce that single dependency.

@Adambean Adambean merged commit 8e4ebe1 into Adambean:main May 27, 2026
1 check failed
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.

2 participants