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.

Using Truebit To Encrypt Sha256 Using Bun.js

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.

πŸ“„ main.js

Try Out

We will use the Truebit CLI to compile and try our source code. Once the code is finished, we will deploy it to the coordination hub so that everyone who knows the namespace and taskname.

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 command against Truebit node to get an instrumented Truebit task.

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

Output

Step 3: Try The Code

Execute the start command against the Truebit node to test our Algorithm.

  • [taskId]: Add the taskId generated in the previous step.

Output

Step 4: Deploy The Task

Last, but not least, Execute the deploy command to deploy our task to the coordination hub, so that anyone with the namespace, taskname and the API key can execute it.

  • [taskId]: Add the taskId generated in step 2

Output

Last updated

Was this helpful?