-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-9qxr-qj54-h672
Co-authored-by: uzlopak <aras.abbasi@googlemail.com>
- Loading branch information
Showing
4 changed files
with
343 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createHash } from 'node:crypto' | ||
import { bench, run } from 'mitata' | ||
import { bytesMatch } from '../../lib/web/fetch/util.js' | ||
|
||
const body = Buffer.from('Hello world!') | ||
const validSha256Base64 = `sha256-${createHash('sha256').update(body).digest('base64')}` | ||
const invalidSha256Base64 = `sha256-${createHash('sha256').update(body).digest('base64')}` | ||
const validSha256Base64Url = `sha256-${createHash('sha256').update(body).digest('base64url')}` | ||
const invalidSha256Base64Url = `sha256-${createHash('sha256').update(body).digest('base64url')}` | ||
|
||
bench('bytesMatch valid sha256 and base64', () => { | ||
bytesMatch(body, validSha256Base64) | ||
}) | ||
bench('bytesMatch invalid sha256 and base64', () => { | ||
bytesMatch(body, invalidSha256Base64) | ||
}) | ||
bench('bytesMatch valid sha256 and base64url', () => { | ||
bytesMatch(body, validSha256Base64Url) | ||
}) | ||
bench('bytesMatch invalid sha256 and base64url', () => { | ||
bytesMatch(body, invalidSha256Base64Url) | ||
}) | ||
|
||
await run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.