123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /**
- * Created by MyPC on 2019/11/7.
- */
- var crypto = require('crypto');
- //加密
- var hashEncode=function (id){//aes192
- var cipher = crypto.createCipher('aes192', CRYPTO_KEY);
- var enc = cipher.update(id, 'utf8', 'hex');
- enc += cipher.final('hex');
- return enc;
- }
- //解密
- var hashDecode=function (id){
- var decipher = crypto.createDecipher('aes192', CRYPTO_KEY);
- var dec = decipher.update(id, 'hex', 'utf8');
- dec += decipher.final('utf8');
- return dec;
- }
- //解密
- var hashStaffDecode=function (id){
- var decipher = crypto.createDecipher('aes-256-ctr', CRYPTO_KEY);
- var dec = decipher.update(id, 'hex', 'utf8');
- dec += decipher.final('utf8');
- return dec;
- }
- var isNumber=function(inputData){
- if (parseFloat(inputData).toString() == "NaN") {
- return false;
- } else {
- return true;
- }
- }
- /**
- * 废弃
- * @param inputData
- * @returns {boolean}
- */
- var isNotANumber=function(inputData){
- if (isNaN(inputData)) {
- return false;
- } else {
- return true;
- }
- }
- //是否存在或者为空
- var isExistence=function (data){
- if(Array.isArray(data)){
- if(data.length==0){
- return false;
- }else{
- return true;
- }
- }else if(Object.prototype.toString.call(data) === '[object Object]'){
- if (JSON.stringify(data) === '{}') {
- return false ;
- }else{
- return true;
- }
- }else if(data==''||data===null||typeof(data) == 'undefined'||data=='undefined'){
- return false;
- }else{
- return true;
- }
- }
- exports.hashDecode = hashDecode;
- exports.hashEncode = hashEncode;
- exports.hashStaffDecode = hashStaffDecode;
- exports.isNotANumber = isNotANumber;
- exports.isNumber=isNumber;
- exports.isExistence = isExistence;
|