﻿# @chikawa222224/testchikawa222224

A Node.js hash library for the bundled `_chikawa222224_testchikawa222224.bin` binary file.

## Hash calculation

The library calculates the hash of these bytes in order:

1. The complete bundled file bytes.
2. The binary attachment decoded from the Base64 argument.

In other words: `hash(fileBytes + Base64Decode(base64Attachment))`.

The default algorithm is SHA-256 and the result is returned as a lowercase hexadecimal string.

## Usage

```js
const { calculateHash } = require("@chikawa222224/testchikawa222224");

const attachmentBase64 = Buffer.from("attachment bytes").toString("base64");
calculateHash(attachmentBase64).then(console.log);
```

Calculate only the bundled file hash by omitting the attachment:

```js
calculateHash().then(console.log);
```

Use another algorithm supported by Node.js:

```js
calculateHash(attachmentBase64, "sha512").then(console.log);
```

## API

### `calculateHash(base64Attachment = "", algorithm = "sha256")`

Returns a `Promise<string>` containing the calculated hash. Invalid Base64 input or an unsupported algorithm rejects the promise.

### `binaryPath`

Contains the absolute path of the bundled binary file.
