标签:
//这里写的是自己遇见的好用顺手的 npm 库,仅供参考
nodejs 发送 http 请求 https://github.com/request/request
如何生成唯一且不可预测的ID https://github.com/broofa/node-uuid
MD5加密 base64加密 https://github.com/node-modules/utility
更简单的MD5 https://github.com/pvorb/node-md5
对URL进行 https://github.com/defunctzombie/node-url
TIPS:
sha1多次加密
var crypto = require(‘crypto‘);
function sha1( data ){
var generator = crypto.createHash(‘sha1‘);
generator.update( data )
return generator.digest(‘hex‘)
}
console.log( sha1(‘adrian‘) )
var url = require(‘url‘);
var a = url.parse(‘http://example.com:8080/one?a=index&t=article&m=default‘);
console.log(a);
//输出结果:
{
protocol : ‘http‘ ,
auth : null ,
host : ‘example.com:8080‘ ,
port : ‘8080‘ ,
hostname : ‘example.com‘ ,
hash : null ,
search : ‘?a=index&t=article&m=default‘,
query : ‘a=index&t=article&m=default‘,
pathname : ‘/one‘,
path : ‘/one?a=index&t=article&m=default‘,
href : ‘http://example.com:8080/one?a=index&t=article&m=default‘
}
标签:
原文地址:http://www.cnblogs.com/muro/p/5421362.html