crypto加密
来源:互联网 发布:白鹤祥java架构师视频 编辑:程序博客网 时间:2024/05/19 03:18
/* hash.js */
var crypto = require('crypto');
module.exports = function(){
this.encode = function(){
var algorithm = arguments[0] ? arguments[0] : ''
, enstring = arguments[1] ? arguments[1] : ''
, returnType = arguments[2] ? arguments[2] : '';
if( algorithm ){
var hash = crypto.createHash(algorithm);
hash.update(enstring);
return hash.digest(returnType);
}
console.log('Please input encryption param');
}
}
/* target.js */
module.exports = function(){
this.encode = function(){}
this.decode = function(){}
}
/* adapter.js */
var util = require('util'),
Target = require('./target');
function Adapter(){
Target.call(this);
this.encode = function(){
var encodeModule = arguments[0] ? arguments[0] : null
, algorithm = arguments[1] ? arguments[1] : ''
, enstring = arguments[2] ? arguments[2] : ''
, returnType = arguments[3] ? arguments[3] : ''
,AdapteeClass = require("./" + encodeModule)
,adapteeObj = new AdapteeClass();
return adapteeObj.encode(algorithm, enstring, returnType, encodeKey, encodeType);
}
}
util.inherits(Adapter,Target);
module.exports = Adapter;
/* test.js */
var AdapterClass = require('./adapter');
var Adapter = new AdapterClass();
var hashEncodeStr = Adapter.encode('hash', 'md5', 'yuejide', 'hex');
console.log(hashEncodeStr);
var http = require('http');
var crypto = require('crypto')
http.createServer(function(req,res){
res.writeHead(200, {'Content-Type' : 'text/html'});
var md5 = crypto.createHash('md5');
var passwd = md5.update('admin').digest('hex');
res.end(passwd);
}).listen(8888);
0 0
- crypto加密
- crypto 加密
- Crypto Columns加密列
- C++加密库 Crypto++
- Node crypto crc32 加密
- nodejs 加密 Crypto
- nodejs加密模块crypto
- express 字符串加密 crypto
- Crypto nodejs 加密
- node 的crypto加密
- nodeJS之crypto加密
- nodeJS之crypto加密
- Crypto API加密通信流程
- Crypto 加密的基本流程
- Crypto API加密通信流程
- 基于crypto++的RSA加密
- JS 加密框架 crypto-js
- JavaScript加密库 Crypto-JS
- CSV导出大量数据
- node.js的generic-pool与mysql结合,mysql连接池
- Anjular组件化
- POJ 2236 Wireless Network(并差集)
- linux脚本使用-------安装madplay及MPlayer播放器脚本分析及命令参数前加“横杠”的背景解释
- crypto加密
- 离散化+multiset —— HDU 4400
- Differential Privacy差分隐私
- Linux操作系统安装与环境配置
- matlab的rem()和mod()函数
- MySQL索引优化实例说明
- 图片预加载代码
- mysql 实验论证 innodb表级锁与行级锁
- HDU 1008 Elevator ACM基础题 关键是读懂题目就OK啦