@@ -176,9 +176,10 @@ private function gpg_data($key, $text)
176176 *
177177 * @param GPG_Public_Key $pk
178178 * @param string $plaintext
179+ * @param string $versionHeader
179180 * @return string encrypted text
180181 */
181- function encrypt ($ pk , $ plaintext )
182+ function encrypt ($ pk , $ plaintext, $ versionHeader = NULL )
182183 {
183184 // normalize the public key
184185 $ key_id = $ pk ->GetKeyId ();
@@ -188,13 +189,17 @@ function encrypt($pk, $plaintext)
188189 $ session_key = GPG_Utility::s_random ($ this ->width , 0 );
189190 $ key_id = GPG_Utility::hex2bin ($ key_id );
190191 $ cp = $ this ->gpg_session ($ key_id , $ key_type , $ session_key , $ public_key ) .
191- $ this ->gpg_data ($ session_key , $ plaintext );
192+ $ this ->gpg_data ($ session_key , $ plaintext );
192193
193194 $ code = base64_encode ($ cp );
194195 $ code = wordwrap ($ code , 64 , "\n" , 1 );
195196
197+ if ($ versionHeader ===NULL ) $ versionHeader ="Version: VerySimple PHP-GPG v " . $ this ->version . "\n\n" ;
198+ else if (strlen ($ versionHeader )>0 )$ versionHeader ="Version: " . $ versionHeader . "\n\n" ;
199+
196200 return
197- "-----BEGIN PGP MESSAGE----- \nVersion: VerySimple PHP-GPG v " .$ this ->version ."\n\n" .
201+ "-----BEGIN PGP MESSAGE----- \n" .
202+ $ versionHeader .
198203 $ code . "\n= " . base64_encode (GPG_Utility::crc24 ($ cp )) .
199204 "\n-----END PGP MESSAGE----- \n" ;
200205 }
0 commit comments