mirror of
https://github.com/emn178/js-sha256.git
synced 2026-08-12 20:32:16 +08:00
## v0.10.0 / 2023-08-30
### Fixed - Chrome bug by workaround. #40 - deprecated `new Buffer`, replace with `Buffer.from`. #34 - dependencies and security issues. #32, #36 ### Changed - TypeScript interface, secretKey can be bytes like message. #23, #25 - remove `eval` and use `require` directly. #18, #26
This commit is contained in:
@@ -48,25 +48,33 @@ var hash2 = sha256.hmac.update('key', 'Message to hash');
|
||||
hash2.update('Message2 to hash');
|
||||
hash2.array();
|
||||
```
|
||||
|
||||
### Node.js
|
||||
If you use node.js, you should require the module first:
|
||||
```JavaScript
|
||||
var sha256 = require('js-sha256');
|
||||
```
|
||||
or
|
||||
or
|
||||
```JavaScript
|
||||
var sha256 = require('js-sha256').sha256;
|
||||
var sha224 = require('js-sha256').sha224;
|
||||
```
|
||||
or
|
||||
```JavaScript
|
||||
const { sha256, sha224 } = require('js-sha256');
|
||||
```
|
||||
### TypeScript
|
||||
or TypeScript
|
||||
```TypeScript
|
||||
import { sha256, sha224 } from 'js-sha256';
|
||||
```
|
||||
### RequireJS
|
||||
It supports AMD:
|
||||
```JavaScript
|
||||
require(['your/path/sha256.js'], function(sha256) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
or TypeScript
|
||||
```TypeScript
|
||||
import { sha256, sha224 } from 'js-sha256';
|
||||
```
|
||||
## Example
|
||||
```JavaScript
|
||||
sha256(''); // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
|
||||
Reference in New Issue
Block a user