-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's old and insecure but it's used in the wild so we need to be able to handle it.
- Loading branch information
1 parent
9af0368
commit 7d5a43b
Showing
4 changed files
with
66 additions
and
1 deletion.
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
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,18 @@ | ||
/* global crypto */ | ||
|
||
import { from } from './hasher.js' | ||
|
||
/** | ||
* @param {AlgorithmIdentifier} name | ||
*/ | ||
const sha = name => | ||
/** | ||
* @param {Uint8Array} data | ||
*/ | ||
async data => new Uint8Array(await crypto.subtle.digest(name, data)) | ||
|
||
export const sha1 = from({ | ||
name: 'sha-1', | ||
code: 0x11, | ||
encode: sha('SHA-1') | ||
}) |
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,11 @@ | ||
// @ts-check | ||
|
||
import crypto from 'crypto' | ||
import { from } from './hasher.js' | ||
import { coerce } from '../bytes.js' | ||
|
||
export const sha1 = from({ | ||
name: 'sha-1', | ||
code: 0x11, | ||
encode: (input) => coerce(crypto.createHash('sha1').update(input).digest()) | ||
}) |
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