vormiaqueryjs
Version:
Vormia Query Js - A npm package for query management with VormiaPHP laravel Backend application
3 lines (2 loc) • 849 B
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("crypto-js");let t;try{t=require("crypto")}catch{t=null}const e=process.env.VORMIA_PUBLIC_KEY,n=process.env.VORMIA_PRIVATE_KEY;exports.decryptWithPrivateKey=function(r,e=n){if(!t||!e)throw new Error("RSA decryption requires Node.js and a private key");const o=Buffer.from(r,"base64"),c=t.privateDecrypt(e,o).toString("utf8");try{return JSON.parse(c)}catch{return c}},exports.encryptData=(t,e)=>{try{const n=JSON.stringify(t);return r.AES.encrypt(n,e).toString()}catch{return null}},exports.encryptWithPublicKey=function(r,n=e){if(!t||!n)throw new Error("RSA encryption requires Node.js and a public key");const o=Buffer.from("string"==typeof r?r:JSON.stringify(r));return t.publicEncrypt(n,o).toString("base64")};
//# sourceMappingURL=encryption.js.map