nodejs加密解密
2015-08-26 11:39
483 查看
nodejs是通集成在内核中的crypto模块来完成加密解密。
常用加密解密模块化代码:
此处,只针对可逆加密。
更详细内容请访问:http://blog.fens.me/nodejs-crypto/
常用加密解密模块化代码:
/** * Created by linli on 2015/8/25. */ var crypto = require('crypto'); //加密 exports.cipher = function(algorithm, key, buf) { var encrypted = ""; var cip = crypto.createCipher(algorithm, key); encrypted += cip.update(buf, 'binary', 'hex'); encrypted += cip.final('hex'); return encrypted }; //解密 exports.decipher = function(algorithm, key, encrypted) { var decrypted = ""; var decipher = crypto.createDecipher(algorithm, key); decrypted += decipher.update(encrypted, 'hex', 'binary'); decrypted += decipher.final('binary'); return decrypted };
此处,只针对可逆加密。
更详细内容请访问:http://blog.fens.me/nodejs-crypto/
相关文章推荐
- MSXML中的SelectNodes和SelectSingleNode
- 后端分布式系列:分布式存储-HDFS DataNode 设计实现解析
- 后端分布式系列:分布式存储-HDFS DataNode 设计实现解析
- 后端分布式系列:分布式存储-HDFS DataNode 设计实现解析
- HDFS DataNode 设计实现解析
- [LeetCode] Swap Nodes in Pairs
- Leetcode: Delete Node in a Linked List
- Delete Node in a Linked List
- Name node is in safe mode.
- iOS Node Conflict svn冲突
- node-zk-browser安装配置
- node.js(八) 有趣的东西才开始哦
- 基于node-red工具实现自定义节点
- [leetcode] 117.Populating Next Right Pointers in Each Node II
- CCCamera,CCAtlasNode源码解析
- CCClippingRectangleNode,CCClippingNode源码解析
- node.js(七) 子进程 child_process模块
- node.js(六) UTIL模块
- [leetcode] 116.Populating Next Right Pointers in Each Node
- node.js(五)字符串转换