JavaScript 加密库Crypto-JS

CryptoJS


CryptoJS是一个纯javascript写的加密类库,使用起来简单方便。目前已支持的算法包括:

  • MD5
  • SHA-1
  • SHA-256
  • AES
  • Rabbit
  • MARC4
  • HMAC
    • HMAC-MD5
    • HMAC-SHA1
    • HMAC-SHA256
  • PBKDF2

具体介绍和下载链接地址:https://code.google.com/archive/p/crypto-js/


CryptoJS库的使用


CryptoJS的使用很方便,只需引用相关的库文件即可。


MD5


MD5 is a widely used hash function. It's been used in a variety of security applications and is also commonly used to check the integrity of files. Though, MD5 is not collision resistant, and it isn't suitable for applications like SSL certificates or digital signatures that rely on this property.

```
var hash = CryptoJS.MD5("Message");

```

SHA-1


The SHA hash functions were designed by the National Security Agency (NSA). SHA-1 is the most established of the existing SHA hash functions, and it's used in a variety of security applications and protocols. Though, SHA-1's collision resistance has been weakening as new attacks are discovered or improved.

```
var hash = CryptoJS.SHA1("Message");

```

SHA-2


SHA-256 is one of the four variants in the SHA-2 set. It isn't as widely used as SHA-1, though it appears to provide much better security.

```
var hash = CryptoJS.SHA256("Message");

```

SHA-512 is largely identical to SHA-256 but operates on 64-bit words rather than 32.

```
var hash = CryptoJS.SHA512("Message");

```



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值