1 /* gpgme.js - Javascript integration for gpgme
2 * Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
4 * This file is part of GPGME.
6 * GPGME is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * GPGME is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * SPDX-License-Identifier: LGPL-2.1+
22 document.addEventListener('DOMContentLoaded', function() {
23 Gpgmejs.init().then(function(gpgmejs){
24 document.getElementById("buttonencrypt").addEventListener("click",
26 let data = document.getElementById('cleartext').value;
27 let keyId = document.getElementById('pubkey').value;
28 gpgmejs.encrypt(data, keyId).then(
32 console.log(answer.data);
33 document.getElementById('answer').value = answer.data;
35 }, function(errormsg){
36 alert( errormsg.code + ' ' + errormsg.msg);
40 document.getElementById("buttondecrypt").addEventListener("click",
42 let data = document.getElementById("ciphertext").value;
43 gpgmejs.decrypt(data).then(
47 document.getElementById('answer').value = answer.data;
49 }, function(errormsg){
50 alert( errormsg.code + ' ' + errormsg.msg);
54 function(error){console.log(error)});