Created
June 1, 2021 00:20
-
-
Save kuc-arc-f/554ca229da7d228f4d8f41c08bb72fb3 to your computer and use it in GitHub Desktop.
sapper , bcrypt sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sapper , bcrypt sample | |
const bcrypt = require('bcrypt'); | |
// | |
export async function get(req, res) { | |
try{ | |
const input_pass= "pas123" | |
let hashed_password = bcrypt.hashSync(input_pass , 10); | |
console.log( hashed_password ) | |
if(bcrypt.compareSync(input_pass, hashed_password )){ | |
console.log( "compareSync OK" ) | |
} | |
res.writeHead(200, { | |
'Content-Type': 'application/json' | |
}); | |
res.end(JSON.stringify([])); | |
} catch (err) { | |
console.error(err); | |
res.writeHead(500, {'Content-Type': 'application/json' }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment