import { __commonJS } from "../../../../_virtual/rolldown_runtime.mjs";
import { require_jsbn } from "../libs/jsbn.mjs";
import { require_schemes } from "../schemes/schemes.mjs";

//#region ../../node_modules/node-rsa/src/encryptEngines/js.js
var require_js = /* @__PURE__ */ __commonJS({ "../../node_modules/node-rsa/src/encryptEngines/js.js": ((exports, module) => {
	var BigInteger = require_jsbn();
	var schemes = require_schemes();
	module.exports = function(keyPair, options) {
		var pkcs1Scheme = schemes.pkcs1.makeScheme(keyPair, options);
		return {
			encrypt: function(buffer, usePrivate) {
				var m, c;
				if (usePrivate) {
					m = new BigInteger(pkcs1Scheme.encPad(buffer, { type: 1 }));
					c = keyPair.$doPrivate(m);
				} else {
					m = new BigInteger(keyPair.encryptionScheme.encPad(buffer));
					c = keyPair.$doPublic(m);
				}
				return c.toBuffer(keyPair.encryptedDataLength);
			},
			decrypt: function(buffer, usePublic) {
				var m, c = new BigInteger(buffer);
				if (usePublic) {
					m = keyPair.$doPublic(c);
					return pkcs1Scheme.encUnPad(m.toBuffer(keyPair.encryptedDataLength), { type: 1 });
				} else {
					m = keyPair.$doPrivate(c);
					return keyPair.encryptionScheme.encUnPad(m.toBuffer(keyPair.encryptedDataLength));
				}
			}
		};
	};
}) });

//#endregion
export default require_js();

export { require_js };
//# sourceMappingURL=js.mjs.map