3

I'm looking in both @solana/web3.js and @project-serum/anchor and don't see any hashing utils. What should one use to pack and hash data in nodejs? I suppose I could use ethereum/web3.js, but pulling in an Ethereum dependency for this seems odd.

Thanks

3
  • If you're referring to serialization, generally the standard is borsh, which ironically is maintained by Near (github.com/near/borsh-js). If you're referring to hashing, I would just use the standard crypto library provided by nodejs (nodejs.org/api/crypto.html) which provides access to most hash algorithms you might use.
    – McBain
    Commented Aug 16, 2022 at 22:28
  • 1
    @ElliotSolskjaer the borsh-js library is EXACTLY what I needed. Considering BorshSerialize is how data is packed in Rust, this companion nodejs library saved me. Give an official answer, and I'll approve it. Thank you!
    – britt
    Commented Aug 16, 2022 at 23:16
  • Glad I could help :). Just added an official answer
    – McBain
    Commented Aug 16, 2022 at 23:36

1 Answer 1

3

If you're referring to serialization, generally the standard for Solana & Rust is Borsh, which you can use in javascript with borsh-js.

If you're referring to hashing, I would just use the crypto library provided by nodejs which provides access to most hash algorithms you might use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.