{"version":3,"file":"Hasher.mjs","names":[],"sources":["../../../src/crypto/hashes/Hasher.ts"],"sourcesContent":["import { CredoError } from '../../error'\nimport { TypedArrayEncoder } from '../../utils'\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,KAAK,GAAG;AACtF,UAAQ,SAAS,aAAa,EAA9B;GACE,KAAK,UACH,QAAO,IAAI,QAAQ,CAAC,KAAK,UAAU;GACrC,KAAK,UACH,QAAO,IAAI,QAAQ,CAAC,KAAK,UAAU;GACrC,KAAK,UACH,QAAO,IAAI,QAAQ,CAAC,KAAK,UAAU;GACrC,KAAK,QACH,QAAO,IAAI,MAAM,CAAC,KAAK,UAAU;GACnC,QACE,OAAM,IAAI,WAAW,eAAe,SAAS,qBAAqB"}