What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-20 03:10:13
update password before saving to mongodb
var mongoose = require('mongoose'), Schema = mongoose.Schema, bcrypt = require('bcrypt'), SALT_WORK_FACTOR = 10; var UserSchema = new Schema({ username: { type: String, required: true, index: { unique: true } }, password: { type:... Add solution -
Go 2022-03-02 10:40:01
bcrypt golang
package util import ( "github.com/sirupsen/logrus" "golang.org/x/crypto/bcrypt" ) func HashPassword(password string) string { pw := []byte(password) result, err := bcrypt.GenerateFromPassword(pw, bcrypt.DefaultCost) if err != ni... Add solution -
Javascript 2021-09-10 09:00:04
how to hash password in node js
npm i bcrypt const bcrypt = require('bcrypt'); async function hashIt(password){ const salt = await bcrypt.genSalt(6); const hashed = await bcrypt.hash(password, salt); } hashIt(password); // compare the password user entered with hashed pass. async f... Add solution