#include "func.h" #include "glob.h" #include "Buffer.h" Pass* find_password(Buffer* buff, const char* label) { Pass* passwords = (Pass*)buff->buffer; for (int i = 0; i < buff->taken / sizeof(Pass); i++) { if (glob(label, passwords[i].label) == Glob_Result::MATCHED) { return &passwords[i]; } } return nullptr; } void generate_password(char* password) { srand(time(NULL)); char characters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&*()_-+={[}]|:;<,>.?"; for (int i = 0; i < MAX_STRING_SIZE; i++) { password[i] = characters[rand() % (sizeof(characters) - 1)]; } password[MAX_STRING_SIZE - 1] = '\0'; } bool save_buffer_to_file(Buffer* buffer) { std::ofstream file("passwords.bin", std::ios::binary); if (!file.is_open()) { printf_s("Error saving file\n"); return false; } file.write((char*)buffer->buffer, buffer->taken); file.close(); return true; } bool load_buffer_from_file(Buffer* buffer) { std::ifstream file("passwords.bin", std::ios::binary); if (!file.is_open()) return false; file.seekg(0, std::ios::end); buffer->resize(file.tellg()); file.seekg(0, std::ios::beg); file.read((char*)buffer->buffer, buffer->size); if (file) buffer->taken = buffer->size; else buffer->taken = file.gcount(); file.close(); return true; } void print_usage() { printf_s(" Usage:\n\n"); printf_s(" password_manager.exe [flags]\n\n"); printf_s(" Note: