-
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.
- Loading branch information
Showing
7 changed files
with
29 additions
and
24 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,20 +1,26 @@ | ||
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 { RSAHashAlgorithm } from "./rsa/common.ts"; | ||
|
||
export function digest( | ||
algorithm: "sha1" | "sha256", | ||
algorithm: RSAHashAlgorithm, | ||
m: Uint8Array, | ||
): Uint8Array { | ||
if (algorithm === "sha1") { | ||
return sha1(m) as Uint8Array; | ||
} else if (algorithm === "sha256") { | ||
return sha256(m) as Uint8Array; | ||
} else if (algorithm === "sha512") { | ||
return sha512(m) as Uint8Array; | ||
} | ||
|
||
throw "Unsupport hash algorithm"; | ||
} | ||
|
||
export function digestLength(algorithm: "sha1" | "sha256") { | ||
export function digestLength(algorithm: RSAHashAlgorithm) { | ||
if (algorithm === "sha512") return 64; | ||
if (algorithm === "sha256") return 32; | ||
|
||
return 20; | ||
} |
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
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
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
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
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
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