diff options
Diffstat (limited to 'demo.php')
-rw-r--r-- | demo.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/demo.php b/demo.php new file mode 100644 index 0000000..87e8dc3 --- /dev/null +++ b/demo.php @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html> + +<script> +function myFunction() { + const socket = new WebSocket("ws://localhost:8765"); + htmlTagArray = document.getElementsByClassName('GNUPG_OVER_WEB'); + for (htmlTag of htmlTagArray) { + //console.log(htmlTag); + socket.addEventListener("open", (event) => { + socket.send(htmlTag.innerHTML); + }); + socket.addEventListener("message", (event) => { + htmlTag.innerHTML = event.data; + }); + } +} +</script> + +<body onload="myFunction();"> +<div class="GNUPG_OVER_WEB"> + +<?php +putenv("GNUPGHOME=/tmp"); +$pubkey = "-----BEGIN PGP PUBLIC KEY BLOCK----- +... +zUP6k/HUWxUzR0wm/kKn5tkycQ== +=LKyt +-----END PGP PUBLIC KEY BLOCK-----"; + +$gnupg_ctx = gnupg_init(); +gnupg_import($gnupg_ctx, $pubkey); +gnupg_addencryptkey($gnupg_ctx, "YOUR_KEY_ID"); + +$enc_string = gnupg_encrypt($gnupg_ctx, "It works!"); +echo $enc_string; +?> +</div> +</body> +</html> |