yutent 1b7142d114 更新readme 2024-05-29 12:26:48 +08:00
src base64改用原生实现 2024-05-29 12:23:04 +08:00
.gitignore 1.0.0 2023-02-13 19:18:15 +08:00
.npmignore base64改用原生实现 2024-05-29 12:23:04 +08:00
.prettierrc.yaml 1.0.0 2023-02-13 19:18:15 +08:00
Readme.md 更新readme 2024-05-29 12:26:48 +08:00
Readme_EN.md 更新readme 2024-05-29 12:26:48 +08:00
build.js 1.0.0 2023-02-13 19:18:15 +08:00
package.json 更新readme 2024-05-29 12:26:48 +08:00

Readme_EN.md

crypto.js browser edition, which provides regular using

中文 Readme

Thanks this library:

  1. spark-md5, After some testing, this is indeed the highest performing version in the pure JS version. It has been introduced into this warehouse and adjusted to be used in ESM mode.

This library is included in index.js. If you have specific requirements on size, you can use them separately.

// all in one
import { sha1, hmac, md5, base64encode } from '//unpkg.com/crypto.web.js/dist/index.js'

// md5
import { md5, md5Sum } from '//unpkg.com/crypto.web.js/dist/md5.js'

// base64
import { base64encode, base64decode } from '//unpkg.com/crypto.web.js/dist/base64.js'

import { sha1, hmac } from '//unpkg.com/crypto.web.js/dist/crypto.js'

APIs

1. md5(str<String>|<Number>)

regular md5 function, you can use to calculate a small string(<100MB).

2. md5Sum(ab<ArrayBuffer>)

you can use this to calculate a large data. Need an ArrayBuffer object which can get the value through FileReader , and the Blob object of the new browser also has an arraybuffer prototype method。

3. base64encode(str<String>)

Base64 encoding, supports Chinese.

4. base64decode(str<String>)

Base64 decoding.

5. uuid()

Generate a unique 24-bit random string. Only guarantees uniqueness on a single machine.

6. ab2hex(ab<ArrayBuffer>)

Convert an arraybuffer object to a hexadecimal string.

7. ab2bin(ab<ArrayBuffer>)

Convert an arraybuffer object to a Binary string.

8. sha1(str<String>)

Calculate the sha1 value of the specified string.

Note: The return value of this method is not a string, but a Promise object.

9. sha256(str<String>)

Calculate the sha256 value of the specified string.

Note: The return value of this method is not a string, but a Promise object.

10. sha512(str<String>)

Calculate the sha512 value of the specified string.

Note: The return value of this method is not a string, but a Promise object.

11. hash(algorithm<String>, data<String>|<ArrayBuffer>|<Uint8Array>)

Hash algorithm, used to implement fuzzy processing of some important data, to achieve the purpose of hiding plaintext. The above sha1, sha256, etc., are actually based on this re-encapsulation result; algorithm, optional values are: SHA-1, SHA-256, SHA-384, SHA-512.

Note: The return value of this method is not a string, but a Promise object.

12. hmac(algorithm<String>, data<String>|<ArrayBuffer>|<Uint8Array>, key<String>|<Uint8Array>, outEncode<String>)

HMAC algorithm, which is a combination of a hash algorithm and a key to prevent the destruction of signature integrity. Compared with the above hash algorithm, it has an additional key parameter.

Note: The return value of this method is not a string, but a Promise object.

浏览器端的加密库
JavaScript 100%