I’m trying to encrypt the payload using JWT Framework v2.2 as follow
$jws_payload = "sdvsd.....";
$kid = "AH1111";
$keyEncryptionAlgorithmManager = new AlgorithmManager([
new RSAOAEP256(),
]);
$keyEncryptionAlgorithmManager = new AlgorithmManager([
new RSAOAEP256(),
]);
$compressionMethodManager = new CompressionMethodManager([]);
$jweBuilder = new JWEBuilder(
$keyEncryptionAlgorithmManager,
$contentEncryptionAlgorithmManager,
$compressionMethodManager
);
$jwk = new JWK([
'kty' => 'RSA',
'n' => $public_key_plain,
"kid" => $this->kid
]);
$jwe = $jweBuilder
->create() // We want to create a new JWE
->withPayload($jws_payload) // We set the payload
->withSharedProtectedHeader([
'alg' => 'RSA-OAEP-256', // Key Encryption Algorithm
'enc' => 'A256GCM', // Content Encryption Algorithm
'kid' => $kid // We enable the compression (irrelevant as the payload is small, just for the example).
])
->addRecipient($jwk) // We add a recipient (a shared key or public key).
->withAAD($aad)
->build();
but following fatal error thrown:
RangeException: Base64::decode() only expects characters in the correct base64 alphabet in ...jwt-framework-2.2.xvendorparagonieconstant_time_encodingsrcBase64.php on line 229
I found it thrown when trying to decode each 4-chars block of public key including slash character like fbf/