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/doc/encrypted.js

17 lines
585 B
JavaScript
Raw Normal View History

2021-03-10 15:27:43 +00:00
const crypto = require('crypto');
const got = require('got');
2021-03-18 10:38:05 +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-10 15:27:43 +00:00
};
2021-03-18 10:38:05 +00:00
exports.encryptPassword = encryptPassword;