Get started with openpgp CDN

LGPL-3.0 licensed

OpenPGP: library for encryption, decryption, digital signatures, and key management per OpenPGP standard.

Tags:
  • crypto
  • pgp
  • gpg
  • openpgp

Stable version

Copied!

How to start using openpgp CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with openpgp CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/openpgp@5.11.1/dist/openpgp.min.js"></script>
</head>
<body>
  <script>
    async function encryptMessage() {
      const key = await OpenPGP.generateKey({
        type: OpenPGP.KeyType.RSA,
        bits: 2048,
      });

      const message = "Hello, World!";
      const encryptedData = await OpenPGP.encrypt({
        key,
        data: message,
      });

      console.log("Encrypted data:", encryptedData);

      const decryptedData = await OpenPGP.decrypt({
        encryptedData,
        privateKey: key,
      });

      console.log("Decrypted data:", decryptedData.data.toString());
    }

    encryptMessage().catch((err) => console.error("Error:", err));
  </script>
</body>
</html>

All versions