Skip to content

Commit

Permalink
Create SQL Instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
Walnit authored Nov 4, 2024
1 parent 333ce9a commit 4337bfe
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions backend/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Replacing Passwords:

Run this code in NodeJS:
```js
const { scrypt, randomBytes } = require("crypto");

function hash(password) {
const salt = randomBytes(16).toString("hex");
const buf = new Promise((res, rej) =>
scrypt(password, salt, 64, (err, buf) => (err ? rej(err) : console.log(
`${buf.toString("hex")}.${salt}`
))))
}

hash("PASSWORD");
```
Now we can put it in the table.
Look for the UID using `SELECT * FROM users;`
Update using `UPDATE users SET password='HASH' WHERE uid='uid';`
Delete using `DELETE FROM users WHERE uid='uid';`
Add using `INSERT INTO users values ('uid', 'username'...);`

0 comments on commit 4337bfe

Please sign in to comment.