2

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. Aug 16 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
    Aug 16 at 23:16
  • Glad I could help :). Just added an official answer Aug 16 at 23:36

1 Answer 1

2

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, privacy policy and cookie policy

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