swc/bundler/tests/.cache/deno/d1745064f6aff60fdf50815e4b14d6d5d6772d8c.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

27 lines
668 B
TypeScript

// Loaded from https://deno.land/x/god_crypto@v1.4.3/src/hash.ts
import { sha1 } from "https://denopkg.com/chiefbiiko/sha1@v1.0.3/mod.ts";
import { sha256 } from "https://denopkg.com/chiefbiiko/sha256@v1.0.2/mod.ts";
export function createHash(algorithm: string) {
return new class {
protected m: Uint8Array = new Uint8Array();
public update(b: Uint8Array) {
this.m = b;
return this;
}
public digest() {
if (algorithm === "sha1") {
return sha1(this.m) as Uint8Array;
} else if (algorithm === "sha256") {
return sha256(this.m) as Uint8Array;
}
throw "Unsupport hash algorithm";
}
}();
}