aboutsummaryrefslogtreecommitdiff
path: root/demo.php
diff options
context:
space:
mode:
authorPasha <pasha@member.fsf.org>2023-12-17 19:37:05 +0000
committerPasha <pasha@member.fsf.org>2023-12-17 19:37:05 +0000
commit551f957d57cb930bfcfd46e763a6556b2e50ec72 (patch)
treec6c96c79994bf9be8cb78d2997098f9c5ab034c5 /demo.php
downloadgnupg_over_web-551f957d57cb930bfcfd46e763a6556b2e50ec72.tar.gz
gnupg_over_web-551f957d57cb930bfcfd46e763a6556b2e50ec72.tar.bz2
initial commit
Diffstat (limited to 'demo.php')
-rw-r--r--demo.php40
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>