php-gnupg/tests/gnupg_res_encrypt.phpt

29 lines
559 B
Text
Raw Normal View History

2006-11-03 12:39:53 +00:00
--TEST--
encrypt and decrypt a text
2018-05-17 19:15:14 +00:00
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
2006-11-03 12:39:53 +00:00
--FILE--
<?php
2018-05-17 19:15:14 +00:00
require_once "gnupgt.inc";
gnupgt::import_key();
2006-11-03 12:39:53 +00:00
$gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_addencryptkey($gpg, $fingerprint);
$enc = gnupg_encrypt($gpg, $plaintext);
$gpg = NULL;
$gpg = gnupg_init();
gnupg_adddecryptkey($gpg, $fingerprint, $passphrase);
$ret = gnupg_decrypt ($gpg, $enc);
var_dump($ret);
?>
--EXPECTF--
string(7) "foo bar"
2018-05-17 19:15:14 +00:00
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>