Encrypt Sha256 Using Deno

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 Deno

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

The Code

You can find the "encrypt sha256" using deno example within the folder truebit-nextgen-examples/function-tasks/js/sha256-deno.

πŸ“„ main.js

Trying Out

We will use the Truebit CLI to compile and test our source code. Once finalized, we will deploy 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 command against Truebit node to get an instrumented Truebit task.

truebit build truebit-nextgen-examples/function-tasks/js/sha256-deno -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?