{"version":3,"file":"Hasher.mjs","names":[],"sources":["../../../src/crypto/hashes/Hasher.ts"],"sourcesContent":["import { CredoError } from '../../error'\nimport { TypedArrayEncoder } from '../../utils/TypedArrayEncoder'\n\nimport { Sha1 } from './Sha1'\nimport { Sha256 } from './Sha256'\nimport { Sha384 } from './Sha384'\nimport { Sha512 } from './Sha512'\n\nexport type HashName = 'sha-512' | 'sha-384' | 'sha-256' | 'sha-1'\n\n// biome-ignore lint/complexity/noStaticOnlyClass: no explanation\nexport class Hasher {\n  public static hash(data: Uint8Array | string, hashName: HashName | ({} & string)): Uint8Array {\n    const dataInput = typeof data === 'string' ? TypedArrayEncoder.fromUtf8String(data) : data\n    switch (hashName.toUpperCase()) {\n      case 'SHA-512':\n        return new Sha512().hash(dataInput)\n      case 'SHA-384':\n        return new Sha384().hash(dataInput)\n      case 'SHA-256':\n        return new Sha256().hash(dataInput)\n      case 'SHA-1':\n        return new Sha1().hash(dataInput)\n      default:\n        throw new CredoError(`Hash name: '${hashName}' is not supported.`)\n    }\n  }\n}\n"],"mappings":";;;;;;;;AAWA,IAAa,SAAb,MAAoB;CAClB,OAAc,KAAK,MAA2B,UAAgD;EAC5F,MAAM,YAAY,OAAO,SAAS,WAAW,kBAAkB,eAAe,IAAI,IAAI;EACtF,QAAQ,SAAS,YAAY,GAA7B;GACE,KAAK,WACH,OAAO,IAAI,OAAO,CAAC,CAAC,KAAK,SAAS;GACpC,KAAK,WACH,OAAO,IAAI,OAAO,CAAC,CAAC,KAAK,SAAS;GACpC,KAAK,WACH,OAAO,IAAI,OAAO,CAAC,CAAC,KAAK,SAAS;GACpC,KAAK,SACH,OAAO,IAAI,KAAK,CAAC,CAAC,KAAK,SAAS;GAClC,SACE,MAAM,IAAI,WAAW,eAAe,SAAS,oBAAoB;EACrE;CACF;AACF"}