Closed Jacobinoo closed 1 year ago
The new SymmetricKey
constructor expects you to pass in the raw key material as bytes. If you have the key exported as hex, you'd need to replace your first line with something like:
$sharedKey = new SymmetricKey(hex2bin("feed3e081af0fdfdfbdaac45421cbdc1139e06cd52ec15bd4c7c4522cecfb314"), new Version3);
Makes sense! Thank you so much :))
I have generated the secret local key using PASETO V3 on Node.js, and then converted it from KeyObject to hex. However the secret key is not compatible with PASETO PHP.
Generated secret key: feed3e081af0fdfdfbdaac45421cbdc1139e06cd52ec15bd4c7c4522cecfb314 Generated token: _v3.local.SwguoFUJpfByqaQiEhEhe9sM63XhvEkY_mXOkdDcIt7-Gi1D8CrnkaSEO-EXPgGTobUF5Gyvq51pLRDUBu-aAShnjRkaRlulID4JMvoatxieQ7k9qAIDX9nQ_dt-rCx_2Y1eV-cahtK6ovrAFlxMthQf4mwWFyJDlggLBd3wzMfDjV-ci78uIRcQdpKvL37bWeUon2t8OOC0sKImZGoSAr6uNpSUNFG
I can decrypt it in Node, but in PHP an error is returned: ParagonIE\Paseto\Exception\SecurityException: Invalid MAC for given ciphertext**
Am I doing something wrong or the secret keys are incompatible with other platforms?
PHP code:
Node: