Import Sha256 "mo:sha256/SHA256";

I have a basic question. I want to use mo:sha256 library and tested the import in motoko playground and it works. however, in my server, it complains that the library does not exist. How can I add this library so that I can import it?
import Sha256 “mo:sha256/SHA256”;

I know it should be through vessel or in dfx.json dependencies, but not sure how

I tried setting it in dependencies of vessel.dhall but got this error while deploying:

Ah, found the issue, should also have added it in package-set.dhal


what version did you use in you packageset? I couldnt find a version?

Other than adding

import SHA256 "mo:sha256/SHA256"; in or wherever you’re using it,

exactly what else needs to be done (npm installs, config changes, etc) to be able to use it?

I’m getting package "sha256" not defined Motoko

Timo says it should be part of the standard packages now: "SHA256/" does not exist · Issue #10 · enzoh/motoko-sha · GitHub

Do I have an old version of something?

I’d suggest: GitHub - aviate-labs/ Crypto Package for Motoko

You should use vessel and/or mops for package management.

Vessel is super simple…you just add delcarations that point to the github repo and the version…if the code is under ‘/src’ then it ‘just works’.

1 Like