> For the complete documentation index, see [llms.txt](https://devs.truebit.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/function-task-examples/encrypt-sha256-using-bun.js.md).

# Encrypt Sha256 Using bun.js

### Description

**This is a simple example of how to calculate a message hash and output the results formatted as a hex string.**

### Encrypting Sha256 Using Bun.js <a href="#using-bacalhau-to-execute-duckdb-processing" id="using-bacalhau-to-execute-duckdb-processing"></a>

To get a verified result, we can use Truebit to execute the *Sha256* task.

### The Code

You can find the "Encrypt Sha256" using *bun.js* example within the folder *truebit-nextgen-examples/function-tasks/js/sha256-bunjs.*

{% tabs %}
{% tab title="Js" %}
📄 main.js
{% endtab %}
{% endtabs %}

### Trying Out

We will use the [Truebit CLI](https://devs.truebit.io/developing-truebit-tasks/truebit-cli-reference.md) to [compile](https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/function-task-examples/reverse-alphabet.md#step-2-build-the-source-code) and [test](https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/function-task-examples/reverse-alphabet.md#step-3-try-the-code) our source code. Once finalized, we will [deploy](#step-4-deploy-the-task) it to the Coordination Hub so that any user with the `namespace` and `taskname` can access or execute it.

#### Step 1: Create The Sha256 Source Code

You will find a file called main.js in the root folder.

#### Step 2: Build The Source Code

Execute the [build](https://devs.truebit.io/developing-truebit-tasks/truebit-cli-reference.md#build) command against Truebit node to get an instrumented Truebit task.

{% code overflow="wrap" %}

```bash
truebit build truebit-nextgen-examples/function-tasks/js/sha256-bunjs -l js
```

{% endcode %}

#### Output

{% code overflow="wrap" %}

```bash
Building the function task
Your function task is ready.
Use the following TaskId for execution or deployment: <taskId>
```

{% endcode %}

#### Step 3: Try The Code

Execute the [start](https://devs.truebit.io/developing-truebit-tasks/truebit-cli-reference.md#start) command against the Truebit node to test our Algorithm.&#x20;

{% code overflow="wrap" %}

```bash
truebit start <taskId> Truebit
```

{% endcode %}

* \[taskId]: Add the `taskId` generated in the previous step.&#x20;

#### Output

{% code overflow="wrap" fullWidth="false" %}

```bash
Executing the function Task
Execution Id: fa1ec9a7-aa7f-4676-a4fc-fedfa7fbd033
Task executed with status: succeed
Task executed with result: 359030d9e4e3b12d50b0b3bec7a25e9491d6618a4432ced99448f947cfc71d01
Task resource usage:
┌───────────────┬───────────────┬───────────────┬───────┬─────────────┬──────────┐
│ (index)       │ Unit          │ Limits        │ Peak  │ Last status │ Capacity │
├───────────────┼───────────────┼───────────────┼───────┼─────────────┼──────────┤
│ Gas           │ 'Steps'       │ 1099511627776 │ 'N/A' │ 7114147279  │ 155      │
│ Nested calls  │ 'Calls'       │ 65536         │ 15011 │ 14964       │ 4        │
│ Frame memory  │ 'Bytes'       │ 524288        │ 46220 │ 44909       │ 11       │
│ System memory │ '64 Kb pages' │ 2048          │ 160   │ '𝚫 1'       │ 13       │
└───────────────┴───────────────┴───────────────┴───────┴─────────────┴──────────┘
```

{% endcode %}

#### Step 4: Deploy The Task

Last, but not least, Execute the [deploy](https://devs.truebit.io/developing-truebit-tasks/truebit-cli-reference.md#deploy) command to deploy our task to the coordination hub, so that anyone with the namespace, taskname and the [API key](https://devs.truebit.io/developing-truebit-tasks/task-authorization.md#task-authorization-process) can execute it.

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>truebit deploy &#x3C;namespace> &#x3C;taskname> --taskId &#x3C;taskId>
</strong></code></pre>

* \[`taskId`]: Add the taskId generated in step 2.

#### Output

{% code overflow="wrap" %}

```
The function task has been deployed successfully.
The Task <taskName> version <version> was registered successfully in namespace <namespace>
```

{% endcode %}
