@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
28 lines (24 loc) • 945 B
JavaScript
import { CredoError } from "../../error/CredoError.mjs";
import "../../error/index.mjs";
import { TypedArrayEncoder } from "../../utils/TypedArrayEncoder.mjs";
import { Sha1 } from "./Sha1.mjs";
import { Sha256 } from "./Sha256.mjs";
import { Sha384 } from "./Sha384.mjs";
import { Sha512 } from "./Sha512.mjs";
import "../../utils/index.mjs";
//#region src/crypto/hashes/Hasher.ts
var Hasher = class {
static hash(data, hashName) {
const dataInput = typeof data === "string" ? TypedArrayEncoder.fromUtf8String(data) : data;
switch (hashName.toUpperCase()) {
case "SHA-512": return new Sha512().hash(dataInput);
case "SHA-384": return new Sha384().hash(dataInput);
case "SHA-256": return new Sha256().hash(dataInput);
case "SHA-1": return new Sha1().hash(dataInput);
default: throw new CredoError(`Hash name: '${hashName}' is not supported.`);
}
}
};
//#endregion
export { Hasher };
//# sourceMappingURL=Hasher.mjs.map