Skip to content

Commit

Permalink
Merge pull request #26 from cloudydeno/patch-1
Browse files Browse the repository at this point in the history
Use /std/hash instead of denopkg.com/chiefbiiko
  • Loading branch information
invisal authored Jan 22, 2021
2 parents 25ec83d + a135a29 commit b6826c1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/hash.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { sha1 } from "https://denopkg.com/chiefbiiko/[email protected]/mod.ts";
import { sha256 } from "https://denopkg.com/chiefbiiko/[email protected]/mod.ts";
import { sha512 } from "https://denopkg.com/chiefbiiko/sha512/mod.ts";
import { Sha1 } from "https://deno.land/[email protected]/hash/sha1.ts";
import { Sha256 } from "https://deno.land/[email protected]/hash/sha256.ts";
import { Sha512 } from "https://deno.land/[email protected]/hash/sha512.ts";
import { RSAHashAlgorithm } from "./rsa/common.ts";

export function digest(
algorithm: RSAHashAlgorithm,
m: Uint8Array,
): Uint8Array {
if (algorithm === "sha1") {
return sha1(m) as Uint8Array;
return new Uint8Array(new Sha1().update(m).arrayBuffer());
} else if (algorithm === "sha256") {
return sha256(m) as Uint8Array;
return new Uint8Array(new Sha256().update(m).arrayBuffer());
} else if (algorithm === "sha512") {
return sha512(m) as Uint8Array;
return new Uint8Array(new Sha512().update(m).arrayBuffer());
}

throw "Unsupport hash algorithm";
Expand Down

0 comments on commit b6826c1

Please sign in to comment.