tags:

views:

45

answers:

2
+1  Q: 

encryption in php

$key = file_get_contents('http://keyserver.pramberger.at/pks/lookup?op=get&search=userid');

this code gives me public key with the html tag .how to extract the public key block form begin pgp public key block ---to---- end pgp public key block and using this public key i need to encrypt the data .i need to do it in php.

+2  A: 

try this
preg_match('/PUBLIC KEY BLOCK-----\s(.*?)\s-----END PGP/s', $data, $match);
echo $match[1]; //returns the key

Frraaz
A: 

or that

$pgp_key = trim(preg_replace('/(.*)<pre>(.*)<\/pre>(.*)/s','\2',$key));
Benjamin Delichère