Add functions to hash and verify hashes using libsodium
This commit is contained in:
parent
45033903cb
commit
07502e1bfc
1 changed files with 14 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue