Skip to content

Would this be a secure way to store passwords in a database? #4535

Closed
@AlexDiego123

Description

@AlexDiego123

Node.js Version

v22.13.0

NPM Version

v11.0.0

Operating System

Windows 10 22H2 (Build 19045.5371)

Subsystem

crypto

Description

Hey, i was searching a good way to store passwords/private data in a database using hashing, would this be a secure way?

const crypto = require('crypto');
const randomSalt = crypto.randomBytes(64).toString('hex'); //generate an unique salt for every password

const data = "hello world"
const saltedData = data + randomSalt;

const hash = crypto.createHash('sha3-512');
hash.update(saltedData);
const hashedData = hash.digest('hex');

//then store hashedData in a database

Minimal Reproduction

  1. Run the code above

Output

No response

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask

Metadata

Metadata

Assignees

No one assigned

    Labels

    answered🎉 Yay! The issue has been resolved, or the question has been answered.question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions