// Master secure development, OWASP top 10, testing, and compliance. Use when building secure systems, conducting security reviews, or implementing best practices.
| name | security-practices |
| description | Master secure development, OWASP top 10, testing, and compliance. Use when building secure systems, conducting security reviews, or implementing best practices. |
import bcrypt from 'bcrypt';
import jwt from 'jsonwebtoken';
// Hash password
const password = 'user_password';
const hash = await bcrypt.hash(password, 10);
// Verify password
const isValid = await bcrypt.compare(password, hash);
// Issue JWT
const token = jwt.sign(
{ userId: 1, email: 'user@example.com' },
process.env.JWT_SECRET,
{ expiresIn: '24h', algorithm: 'HS256' }
);
// Verify JWT
const decoded = jwt.verify(token, process.env.JWT_SECRET);