/**
 * Created by zhang on 2019/5/10.
 */
let crypto = require('crypto');
module.exports ={
    aesEncrypt:aesEncrypt,
    aesDecrypt:aesDecrypt
};


function aesEncrypt(data, key = 'SmartCost') {
    const cipher = crypto.createCipher('aes192', key);
    var crypted = cipher.update(data, 'utf8', 'hex');
    crypted += cipher.final('hex');
    return crypted;
}

function aesDecrypt(encrypted, key= 'SmartCost') {
    const decipher = crypto.createDecipher('aes192', key);
    var decrypted = decipher.update(encrypted, 'hex', 'utf8');
    decrypted += decipher.final('utf8');
    return decrypted;
}