<?php
// Test script to verify data can be decrypted with the master key
require_once('api.php');

echo "Testing data decryption with persistent master key...\n\n";

// Load encryption metadata
$encryptionMeta = loadEncryptionMeta();
echo "Encryption Meta:\n";
print_r($encryptionMeta);
echo "\n";

// Test loading users
echo "Testing Users File:\n";
$users = loadData(USERS_FILE);
echo "Users loaded: " . count($users) . "\n";
if (count($users) > 0) {
    echo "Sample user: " . $users[0]['username'] . "\n";
}
echo "\n";

// Test loading categories
echo "Testing Categories File:\n";
$categories = loadData(CATEGORIES_FILE);
echo "Categories loaded: " . count($categories) . "\n";
echo "\n";

// Test loading posts
echo "Testing Posts File:\n";
$posts = loadData(POSTS_FILE);
echo "Posts metadata loaded: " . count($posts) . "\n";
echo "\n";

// Test loading replies
echo "Testing Replies File:\n";
$replies = loadData(REPLIES_FILE);
echo "Replies metadata loaded: " . count($replies) . "\n";
echo "\n";

echo "Decryption test complete!\n";
?>
