const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
const require_jsbn$1 = require('../libs/jsbn.cjs');
const require_schemes$1 = require('../schemes/schemes.cjs');

//#region ../../node_modules/node-rsa/src/encryptEngines/js.js
var require_js = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/node-rsa/src/encryptEngines/js.js": ((exports, module) => {
	var BigInteger = require_jsbn$1.default;
	var schemes = require_schemes$1.default;
	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
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_js();
  }
});
//# sourceMappingURL=js.cjs.map