Paseto V3 Node.js - Local Secret Key must be 32 bytes long symmetric key Error

600 Views Asked by At

My secret key was generated using PHP Paseto V3 with openssl_random_pseudo_bytes(32) and then converted from bin to hex. Now I need to decrypt and verify Paseto token using node.js and paseto library (https://github.com/panva/paseto). I don't understand why my secret key returns an error that the length is invalid. It was generated using 32 bytes.

The code:

const paseto = require('paseto');
const { V3: { decrypt } } = paseto;

(async () => {
  {
    const payload = await decrypt("example_token", "b244ac595fbe3a6ea8c3fad93f66d15221121428fd03dcccf32203e364f504ed")
  }
})()

An error in node.js: TypeError: v3.local secret key must be 32 bytes long symmetric key

1

There are 1 best solutions below

1
Jacobino On

I figured it out! Solution here and more details here: https://github.com/panva/paseto/discussions/32