MD5
安装 md5-node
npm install md5-node
测试
var md5 = require('md5-node');
console.log(md5('123456'));//e10adc3949ba59abbe56e057f20f883e
字典序排序
比如b=1,a=2,c=3, 排完后是a=2,b=1,c=3
let dict = {a: 3, b:1, c:2};
for (let key of Object.keys(dict).sort()) {
console.log(key, dict[key]);
}
获取时间戳(毫秒,秒)
/**
* 获取当前时间戳(毫秒)
*/
function getNowMilliSecond(){
return Math.floor(Date.now());
}
/**
* 获取当前时间戳(秒)
*/
function getNowSceond(){
return Math.floor(Date.now() / 1000);
}
//当前时间戳(毫秒)
console.log("curMilliSecond=%d",getNowMilliSecond()); //输出:curMilliSecond=1608090151913
//当前时间戳(秒)
console.log("curSecond=%d",getNowSceond()); //输出:curSecond=1608090151