-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from cloudydeno/patch-1
Use /std/hash instead of denopkg.com/chiefbiiko
- Loading branch information
Showing
1 changed file
with
6 additions
and
6 deletions.
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
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"; | ||
|