Closed jamesruan closed 8 years ago
Hi James,
This function is available in the sumo
build.
It is not included in the standard build since no high-level APIs are using it.
SHA-256 is slower than other options and vulnerable to length extension attacks (unlike SHA-512/256 and Blake2), so the only reason for explicitly requiring it is compatibility with legacy applications.
The sumo
build includes everything, not only high-level APIs. So just include the content of browsers-sumo
or modules-sumo
and you will have it!
Thanks for your reply.
I didn't find documents about the 'sumo' version. We will try it.
I'm a colleague of James.
I've download the 'sumo' build, and list all exported functions. Still, the crypto_hash_sha256()
is not in the list.
for(var v in sodium){
console.log(v);
}
$ node
> let sodium = require('libsodium-wrappers')
> sodium
{ add: [Function: add],
compare: [Function: compare],
from_base64: [Function: from_base64],
from_hex: [Function: from_hex],
from_string: [Function: from_string],
increment: [Function: increment],
...
crypto_hash: [Function: crypto_hash],
crypto_hash_sha256: [Function: crypto_hash_sha256],
crypto_hash_sha512: [Function: crypto_hash_sha512],
...
crypto_sign_SEEDBYTES: 32,
SODIUM_VERSION_STRING: '1.0.10',
crypto_pwhash_STRPREFIX: '$argon2i$',
crypto_pwhash_scryptsalsa208sha256_STRPREFIX: '$7$' }
Thanks for your patience.
We probably downloaded an error built version. Current version is OK.
Our project need a browser version of SHA-256. I would like to use libsodium.js for that. To my surprise, I find this function is deliberately not exported.
I see
crypto_hash()
(which is supposed to be a SHA-512-256) is exported. Is there any reason not to export it?Thanks.