static function verifySignature($textToVerify, $signatureInBase64, $publicKeyFile) {

		if (!function_exists("openssl_get_privatekey")) {
			throw new CryptoException("OpenSSL extension in PHP is required. Please install or enable it.");
		}

		if (!file_exists($publicKeyFile) or !is_readable($publicKeyFile)) {
			throw new CryptoException("Public key file \"$publicKeyFile\" not found or not readable.");
		}

		$keyAsString = file_get_contents($publicKeyFile);
		$publicKeyId = openssl_get_publickey($keyAsString);

		$signature = base64_decode($signatureInBase64);

		$res = openssl_verify($textToVerify, $signature, $publicKeyId, self::HASH_METHOD);
		openssl_free_key($publicKeyId);

		if ($res == -1) {
			throw new CryptoException("Verification of signature failed: ".openssl_error_string());
		}

		return $res ? true : false;
	}
static function verifySignature($textToVerify, $signatureInBase64, $publicKeyFile) {

		if (!function_exists("openssl_get_privatekey")) {
			throw new CryptoException("OpenSSL extension in PHP is required. Please install or enable it.");
		}

		if (!file_exists($publicKeyFile) or !is_readable($publicKeyFile)) {
			throw new CryptoException("Public key file \"$publicKeyFile\" not found or not readable.");
		}

		$keyAsString = file_get_contents($publicKeyFile);
		$publicKeyId = openssl_get_publickey($keyAsString);

		$signature = base64_decode($signatureInBase64);

		$res = openssl_verify($textToVerify, $signature, $publicKeyId, self::HASH_METHOD);
		openssl_free_key($publicKeyId);

		if ($res == -1) {
			throw new CryptoException("Verification of signature failed: ".openssl_error_string());
		}

		return $res ? true : false;
	}
static function verifySignature ( $ textToVerify , $ signatureInBase64 , $ publicKeyFile ) { if ( ! function_exists ( "openssl_get_privatekey" ) ) { throw new CryptoException ( "OpenSSL extension in PHP is required. Please install or enable it." ) ; } if ( ! file_exists ( $ publicKeyFile ) or ! is_readable ( $ publicKeyFile ) ) { throw new CryptoException ( "Public key file \"$publicKeyFile\" not found or not readable." ) ; } $ keyAsString = file_get_contents ( $ publicKeyFile ) ; $ publicKeyId = openssl_get_publickey ( $ keyAsString ) ; $ signature = base64_decode ( $ signatureInBase64 ) ; $ res = openssl_verify ( $ textToVerify , $ signature , $ publicKeyId , self :: HASH_METHOD ) ; openssl_free_key ( $ publicKeyId ) ; if ( $ res == - 1 ) { throw new CryptoException ( "Verification of signature failed: " . openssl_error_string ( ) ) ; } return $ res ? true : false ; }
Verifies signature of a string

@param string $textToVerify The text that was signed
@param string $signatureInBase64 The signature encoded with Base64
@param string $publicKeyFile Path to file where bank's public key is saved
(you can obtain it from bank's app https://iposman.iplatebnibrana.csob.cz/posmerchant
or from their package on GitHub)
@return bool True if signature is correct
@throws CryptoException When some cryptographic operation fails and key file path is not valid
Verifies signature of a string