(crypto: ISodium)
| 120 | } |
| 121 | |
| 122 | export async function getKey(crypto: ISodium) { |
| 123 | await crypto.initialize(); |
| 124 | |
| 125 | const saltBytes: Uint8Array = crypto.randombytes_buf( |
| 126 | crypto.crypto_pwhash_SALTBYTES |
| 127 | ); |
| 128 | const key = crypto.crypto_pwhash( |
| 129 | crypto.crypto_aead_xchacha20poly1305_ietf_KEYBYTES, |
| 130 | "mypassword", |
| 131 | saltBytes, |
| 132 | 3, // operations limit |
| 133 | 1024 * 1024 * 8, // memory limit (8MB) |
| 134 | crypto.crypto_pwhash_ALG_ARGON2I13 |
| 135 | ); |
| 136 | return { key, salt: saltBytes }; |
| 137 | } |
| 138 | |
| 139 | export async function hash(crypto: ISodium) { |
| 140 | await crypto.initialize(); |
no test coverage detected