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.
smart-tag/utilities/encrypted.js

17 lines
659 B
JavaScript
Raw Normal View History

2021-03-11 14:41:03 +00:00
const crypto = require('crypto');
const got = require('got');
const config = require('./config');
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");
};
exports.encryptPassword = encryptPassword;