function i(t) {
  var a;
  let n = "";
  const r = new Uint8Array(t);
  for (let e = 0; e < r.byteLength; e++)
    n += String.fromCharCode(r[e]);
  return `-----BEGIN PUBLIC KEY-----
${((a = window.btoa(n).match(/.{1,64}/g)) == null ? void 0 : a.join(`
`)) || ""}
-----END PUBLIC KEY-----`;
}
async function y() {
  return await window.crypto.subtle.generateKey(
    {
      name: "RSA-OAEP",
      modulusLength: 2048,
      publicExponent: new Uint8Array([1, 0, 1]),
      // 65537
      hash: "SHA-256"
    },
    !0,
    // extractable
    ["encrypt", "decrypt"]
  );
}
async function s(t) {
  const n = await window.crypto.subtle.exportKey("spki", t);
  return i(n);
}
async function d(t, n) {
  const r = window.atob(n), o = new Uint8Array(r.length);
  for (let e = 0; e < r.length; e++)
    o[e] = r.charCodeAt(e);
  const c = await window.crypto.subtle.decrypt(
    { name: "RSA-OAEP" },
    t,
    o
  );
  return new TextDecoder().decode(c);
}
export {
  d as decryptWithPrivateKey,
  s as exportPublicKeyPEM,
  y as generateRSAKeyPair
};
//# sourceMappingURL=crypto-DKWV68KF.js.map
