mirror of
https://github.com/hanzoai/jose.git
synced 2026-09-24 17:00:01 +00:00
12 lines
373 B
TypeScript
12 lines
373 B
TypeScript
import crypto from './webcrypto.ts'
|
|
import type { DigestFunction } from './interfaces.d.ts'
|
|
|
|
const digest: DigestFunction = async (
|
|
algorithm: 'sha256' | 'sha384' | 'sha512',
|
|
data: Uint8Array,
|
|
): Promise<Uint8Array> => {
|
|
const subtleDigest = `SHA-${algorithm.slice(-3)}`
|
|
return new Uint8Array(await crypto.subtle.digest(subtleDigest, data))
|
|
}
|
|
export default digest
|