php-jwt icon indicating copy to clipboard operation
php-jwt copied to clipboard

Pass key as string?

Open splitbrain opened this issue 3 years ago • 1 comments

From what I can see in docs, it seems only possible to pass a file path in the constructor. It would be helpful if I could pass the key directly as a string without having to create a file first (in my case it's coming from a database). Is there maybe a trick using the resource method somehow?

splitbrain avatar Jun 30 '22 08:06 splitbrain

i think you can directly set the resource as key.

$key = openssl_pkey_get_private('your rsa key as string from database');
$jwt = new JWT($key, 'RS256');

// ...

adhocore avatar Jun 30 '22 08:06 adhocore

closing for now

adhocore avatar Oct 27 '22 14:10 adhocore