Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions interfaces/final-object.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface FinalObject {
removeTags: string[]; // tags to remove
screenshotSettings: ScreenshotSettings;
version: number; // version of this vha file
password?: string; // Optional password field
}

export interface ImageElement {
Expand Down Expand Up @@ -103,3 +104,20 @@ export interface ScreenshotSettings {
height: AllowedScreenshotHeight;
n: number;
}

//Setting the password
import bcrypt from 'bcrypt';

const saltRounds = 10;

async function setPassword(finalObject: FinalObject, plainPassword: string) {
const hashedPassword = await bcrypt.hash(plainPassword, saltRounds);
finalObject.password = hashedPassword; // Store the hashed password
}

// Verifying the password
async function verifyPassword(finalObject: FinalObject, inputPassword: string) {
if (!finalObject.password) return false; // No password set
const match = await bcrypt.compare(inputPassword, finalObject.password);
return match; // Returns true if the password matches
}