Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
doc: make Web Crypto example spec compliant
subtle.sign is not supposed to support strings, and in most Web Crypto
implementations, it does not. Passing a string as the 'data' argument
only works in Node.js, and users should not rely on that oddity. The
Web Crypto spec requires the data argument to be a BufferSource, i.e.,
an ArrayBuffer or an ArrayBufferView.
  • Loading branch information
tniessen committed Jan 16, 2022
commit f041c27ece1ef8b3b28dc087f8bc87565554dde1
5 changes: 4 additions & 1 deletion doc/api/webcrypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ const { subtle } = require('crypto').webcrypto;
length: 256
}, true, ['sign', 'verify']);

const enc = new TextEncoder();
const message = enc.encode('I love cupcakes');

const digest = await subtle.sign({
name: 'HMAC'
}, key, 'I love cupcakes');
}, key, message);

})();
```
Expand Down