import { createHash } from "crypto"

function hashPassword(password: string): string {
  return createHash("sha256").update(password).digest("hex")
}

export function getAdminToken(): string {
  const password = process.env.ADMIN_PASSWORD || "higgyadmin"
  return hashPassword(password)
}

export function validateAdminToken(token: string): boolean {
  return token === getAdminToken()
}

export function validateAdminPassword(password: string): boolean {
  const expected = process.env.ADMIN_PASSWORD || "higgyadmin"
  return password === expected
}
