Skip to content

Math.random() does not provide cryptographically secure random numbers #1

Description

@bwbroersma

Regarding the generatePassword function, it uses Math.random:

newPassword += charset.charAt(Math.floor(Math.random() * charset.length));

See MDN:

Note: Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the Crypto.getRandomValues() method.

See a this Svelte REPL for a secure implementation of Crypto.getRandomValues().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions