Add functions to hash and verify hashes using libsodium

This commit is contained in:
Vishnu Mohandas 2020-10-01 03:07:37 +05:30
parent 45033903cb
commit 07502e1bfc

View file

@ -39,6 +39,20 @@ class Crypto {
await sodium.ready;
return sodium.crypto_secretbox_open_easy(data, nonce, key);
}
async hash(input) {
await sodium.ready;
return sodium.crypto_pwhash_str(
input,
sodium.crypto_pwhash_MEMLIMIT_SENSITIVE,
sodium.crypto_pwhash_MEMLIMIT_SENSITIVE
);
}
async verifyHash(hash, input) {
await sodium.ready;
return sodium.crypto_pwhash_str_verify(hash, input);
}
}
Comlink.expose(Crypto);