# crypto-js
JavaScript library of crypto standards.
## Node.js (Install)
Requirements:
- Node.js
- npm (Node.js package manager)
```bash
npm install crypto-js
```
### Usage
Modular include:
```javascript
var AES = require("crypto-js/aes");
var SHA256 = require("crypto-js/sha256");
...
console.log(SHA256("Message"));
```
Including all libraries, for access to extra methods:
```javascript
var CryptoJS = require("crypto-js");
console.log(CryptoJS.HmacSHA1("Message", "Key"));
```
## Client (browser)
Requirements:
- Node.js
- Bower (package manager for frontend)
```bash
bower install crypto-js
```
### Usage
Modular include:
```javascript
require.config({
packages: [
{
name: 'crypto-js',
location: 'path-to/bower_components/crypto-js',
main: 'index'
}
]
});
require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
console.log(SHA256("Message"));
});
```
Including all libraries, for access to extra methods:
```javascript
// Above-mentioned will work or use this simple form
require.config({
paths: {
'crypto-js': 'path-to/bower_components/crypto-js/crypto-js'
}
});
require(["crypto-js"], function (CryptoJS) {
console.log(CryptoJS.HmacSHA1("Message", "Key"));
});
```
### Usage without RequireJS
```html
<script type="text/javascript" src="path-to/bower_components/crypto-js/crypto-js.js"></script>
<script type="text/javascript">
var encrypted = CryptoJS.AES(...);
var encrypted = CryptoJS.SHA256(...);
</script>
```
## API
See: https://code.google.com/p/crypto-js
### AES Encryption
#### Plain text encryption
```javascript
var CryptoJS = require("crypto-js");
// Encrypt
var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123');
// Decrypt
var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret key 123');
var plaintext = bytes.toString(CryptoJS.enc.Utf8);
console.log(plaintext);
```
#### Object encryption
```javascript
var CryptoJS = require("crypto-js");
var data = [{id: 1}, {id: 2}]
// Encrypt
var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123');
// Decrypt
var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), 'secret key 123');
var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
console.log(decryptedData);
```
### List of modules
- ```crypto-js/core```
- ```crypto-js/x64-core```
- ```crypto-js/lib-typedarrays```
---
- ```crypto-js/md5```
- ```crypto-js/sha1```
- ```crypto-js/sha256```
- ```crypto-js/sha224```
- ```crypto-js/sha512```
- ```crypto-js/sha384```
- ```crypto-js/sha3```
- ```crypto-js/ripemd160```
---
- ```crypto-js/hmac-md5```
- ```crypto-js/hmac-sha1```
- ```crypto-js/hmac-sha256```
- ```crypto-js/hmac-sha224```
- ```crypto-js/hmac-sha512```
- ```crypto-js/hmac-sha384```
- ```crypto-js/hmac-sha3```
- ```crypto-js/hmac-ripemd160```
---
- ```crypto-js/pbkdf2```
---
- ```crypto-js/aes```
- ```crypto-js/tripledes```
- ```crypto-js/rc4```
- ```crypto-js/rabbit```
- ```crypto-js/rabbit-legacy```
- ```crypto-js/evpkdf```
---
- ```crypto-js/format-openssl```
- ```crypto-js/format-hex```
---
- ```crypto-js/enc-latin1```
- ```crypto-js/enc-utf8```
- ```crypto-js/enc-hex```
- ```crypto-js/enc-utf16```
- ```crypto-js/enc-base64```
---
- ```crypto-js/mode-cfb```
- ```crypto-js/mode-ctr```
- ```crypto-js/mode-ctr-gladman```
- ```crypto-js/mode-ofb```
- ```crypto-js/mode-ecb```
---
- ```crypto-js/pad-pkcs7```
- ```crypto-js/pad-ansix923```
- ```crypto-js/pad-iso10126```
- ```crypto-js/pad-iso97971```
- ```crypto-js/pad-zeropadding```
- ```crypto-js/pad-nopadding```
程序猿小D
- 粉丝: 4334
- 资源: 1195
最新资源
- PS5游戏服务网站的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 课程设计基于hadoop实现的图书推荐系统源码+项目说明(高分课设)
- springboot 电商书城平台系统(已调试)-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 432JSP基于SSH2银行业务管理系统毕业课程源码设计+论文资料+任务书+开题报告+答辩ppt
- springboot校园一卡通_q7e7o--论文-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- springboot校园便利平台_1jxhb--论文-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于vue+python实现在线教育网站的设计与开发
- Matlab小电流接地系统的建模与单相故障的仿真分析(仿真工程文件+结果图+详细设计说明书+介绍PPT) 随着城乡的发展,电力系统开始不断完善,配电网络也的结构也开始复杂,在线缆的铺设上也得到大幅提升
- c语言中自增自减的用法.md
- springboot基于JAVA的企业内部人员绩效量化管理系统_av7p4--论文-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于Java的企业OA管理系统的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- springboot基于Hadoop短视频流量数据分析与可视化_nduy8--论文-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于java的校园服务平台设计与开发-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.rar
- 基于java无人超市管理系统-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于Java的小区物业智能卡管理的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 基于JS的个人云盘管理系统的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈