rsa-oaep-encryption
    Preparing search index...

    Function importPublicKey

    • Import a RSA public key from a PEM format string.

      Parameters

      • pem: string

        The PEM format string containing the public key.

      Returns RSAPublicKey

      An RSAPublicKey object that can be used to encrypt data.

      If the PEM format is invalid or the key cannot be parsed.

      import { importPublicKey, sha256 } from 'rsa-oaep-encryption';

      const PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
      MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...
      -----END PUBLIC KEY-----`;

      const publicKey = importPublicKey(PUBLIC_KEY);
      const encrypted = publicKey.encrypt('Hello, World!', sha256.create());