This repository has been archived on 2024-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
2021-03-11 14:41:03 +00:00
|
|
|
const crypto = require('crypto');
|
|
|
|
const got = require('got');
|
2021-03-16 11:25:32 +00:00
|
|
|
const config = require('../config');
|
2021-03-11 14:41:03 +00:00
|
|
|
|
|
|
|
const encryptPassword = async(password) => {
|
|
|
|
const { body } = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', {
|
|
|
|
});
|
|
|
|
const publicKey=`-----BEGIN PUBLIC KEY-----\n${JSON.parse(body).data}\n-----END PUBLIC KEY-----`;
|
|
|
|
const externKey = {
|
|
|
|
key: publicKey,
|
|
|
|
padding: crypto.constants.RSA_PKCS1_PADDING
|
|
|
|
};
|
|
|
|
let buffer = Buffer.from(password);
|
|
|
|
return crypto.publicEncrypt(externKey, buffer).toString("base64");
|
|
|
|
};
|
|
|
|
|
2021-03-15 16:35:41 +00:00
|
|
|
exports.encryptPassword = encryptPassword;
|