Open Bansi1994 opened 6 months ago
`$publicKey = "-----BEGIN PUBLIC KEY-----\n" . $publicKey . "\n-----END PUBLIC KEY-----";
// Create a new public key resource $publicKeyResource = openssl_pkey_get_public($publicKey);
if (!$publicKeyResource) { throw new Exception('Invalid public key'); }
// Verify the signature $isVerified = openssl_verify($payload, base64_decode($signature), $publicKeyResource, OPENSSL_ALGO_SHA256);
// Free the key resource openssl_free_key($publicKeyResource);
if ($isVerified === 1) { echo "Signature is valid."; } elseif ($isVerified === 0) { echo "Signature is invalid."; } else { echo "Error checking signature: " . openssl_error_string(); }`
I have created key and signature in React-Native and now I want to verify it in php. I am using this code but it's always give me the failure and give me the error like error:0906D06C:PEM routines:PEM_read_bio:no start line .
I am new in php. Please help me with this.
Here is my php code ::