tranxs
Version:
Tranxs is a powerful and easy-to-use Node.js library for integrating M-Pesa payment services into your application. It provides seamless support for all major M-Pesa transactions, including STK Push, B2C, B2B, C2B, Reversal, Account Balance, and Transacti
27 lines • 1.01 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSecurityCredentials = generateSecurityCredentials;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const crypto_1 = require("crypto");
function generateSecurityCredentials(password) {
const secFile = path_1.default.join(__dirname, "cert.cer");
let publicKey;
try {
publicKey = fs_1.default.readFileSync(secFile, "utf8");
}
catch (error) {
console.error("Error reading the public key file", error);
throw error;
}
const buffer = Buffer.from(password);
const encryption = (0, crypto_1.publicEncrypt)({
key: publicKey,
padding: crypto_1.constants.RSA_PKCS1_PADDING,
}, buffer);
return encryption.toString("base64");
}
//# sourceMappingURL=segGen.js.map