Skip to content

Commit 2e54022

Browse files
committed
fix: hash should use subtle from uncrypto
1 parent 9be500c commit 2e54022

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/hash.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { subtle } from "uncrypto";
12
import { base64, base64Url } from "./base64";
23
import type { EncodingFormat, SHAFamily, TypedArray } from "./type";
34

@@ -11,7 +12,7 @@ export function createHash<Encoding extends EncodingFormat = "none">(
1112
): Promise<Encoding extends "none" ? ArrayBuffer : string> => {
1213
const encoder = new TextEncoder();
1314
const data = typeof input === "string" ? encoder.encode(input) : input;
14-
const hashBuffer = await crypto.subtle.digest(algorithm, data);
15+
const hashBuffer = await subtle.digest(algorithm, data);
1516

1617
if (encoding === "hex") {
1718
const hashArray = Array.from(new Uint8Array(hashBuffer));

src/hmac.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expect, it } from "vitest";
22
import { createHMAC } from "./hmac";
3-
import { base64Url } from "./base64";
43

54
describe("hmac module", () => {
65
const algorithm = "SHA-256";

0 commit comments

Comments
 (0)