MD5

安装 md5-node

  1. npm install md5-node

测试

  1. var md5 = require('md5-node');
  2. console.log(md5('123456'));//e10adc3949ba59abbe56e057f20f883e

字典序排序

比如b=1,a=2,c=3, 排完后是a=2,b=1,c=3

  1. let dict = {a: 3, b:1, c:2};
  2. for (let key of Object.keys(dict).sort()) {
  3. console.log(key, dict[key]);
  4. }

获取时间戳(毫秒,秒)

  1. /**
  2. * 获取当前时间戳(毫秒)
  3. */
  4. function getNowMilliSecond(){
  5. return Math.floor(Date.now());
  6. }
  7. /**
  8. * 获取当前时间戳(秒)
  9. */
  10. function getNowSceond(){
  11. return Math.floor(Date.now() / 1000);
  12. }
  13. //当前时间戳(毫秒)
  14. console.log("curMilliSecond=%d",getNowMilliSecond()); //输出:curMilliSecond=1608090151913
  15. //当前时间戳(秒)
  16. console.log("curSecond=%d",getNowSceond()); //输出:curSecond=1608090151