#!/bin/bash

# Password and key generation LibrePortal tags - follows same pattern as port system
# SECURITY: Only generates new passwords for unconfigured tags, never changes existing passwords
tagsProcessorPasswordAndKeyGeneration()
{
    local full_file_path="$1"
    
    # Handle password tags
    for i in {1..20}; do
        local random_password=$(generateRandomPassword)
        tagsManagerUpdateUniversalTag "$full_file_path" "PASSWORD_TAG_$i" "$random_password"
    done
    
    # Handle hex keys
    for i in {1..20}; do
        local hex_key=$(openssl rand -hex 32)
        tagsManagerUpdateUniversalTag "$full_file_path" "HEX_TAG_$i" "$hex_key"
    done
    
    # Handle VAPID keys
    for i in {1..20}; do
        local vapid_key=$(openssl rand -base64 32 | tr -d '+/=' | tr -cd '[:alnum:]')
        tagsManagerUpdateUniversalTag "$full_file_path" "VAPID_TAG_$i" "$vapid_key"
    done
}
