initial commit - far from runnable
This commit is contained in:
commit
db057ce342
8614 changed files with 1032171 additions and 0 deletions
19
src/utils/encryptionUtils.ts
Normal file
19
src/utils/encryptionUtils.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import * as jwt from "jsonwebtoken";
|
||||
import * as bcrypt from "bcrypt";
|
||||
import * as dotenv from "dotenv";
|
||||
import { payload } from "../dtos/userDto";
|
||||
|
||||
dotenv.config();
|
||||
const { JWT_SECRET = "" } = process.env;
|
||||
export class encrypt {
|
||||
static async encryptpass(password: string) {
|
||||
return bcrypt.hashSync(password, 12);
|
||||
}
|
||||
static comparepassword(hashPassword: string, password: string) {
|
||||
return bcrypt.compareSync(password, hashPassword);
|
||||
}
|
||||
|
||||
static generateToken(payload: payload) {
|
||||
return jwt.sign(payload, JWT_SECRET, { expiresIn: "1d" });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue