Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory cost is too small #97

Open
chengdonglin opened this issue Apr 22, 2024 · 3 comments
Open

Memory cost is too small #97

chengdonglin opened this issue Apr 22, 2024 · 3 comments

Comments

@chengdonglin
Copy link

java code the memory set memory 12, I use the some code i web, It tell me memory cost is too small, now we can not change the momory the big, how can I fix the propblem?hehe is code,

export async function argonEncrypt(value) {
const keyData = new TextEncoder().encode(key)
const res= await argon2.hash({
pass: value,
salt: value,
time: 20,
mem: 12,
type: argon2.ArgonType.Argon2id,
hashLen:32,
parallelism: 2
})
return Base64.fromUint8Array(res.hash)
}

@antelle
Copy link
Owner

antelle commented Apr 23, 2024

I guess it’s the limitation of webassembly

@moonsettler
Copy link

hi @antelle, i was looking at your demo site for this and i'm a bit confused by this math (in calc.js): why is a KB defined as 1024*1024?

    const KB = 1024 * 1024;
    const MB = 1024 * KB;
    const GB = 1024 * MB;
    const WASM_PAGE_SIZE = 64 * 1024;

    const totalMemory = (2 * GB - 64 * KB) / 1024 / WASM_PAGE_SIZE;
    const initialMemory = Math.min(
        Math.max(Math.ceil((mem * 1024) / WASM_PAGE_SIZE), 256) + 256,
        totalMemory
    );

@antelle
Copy link
Owner

antelle commented Aug 4, 2024

Don't remember why it is like this tbh. Could be a mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants