The Muggy Weather Robotics Duo

Image
 The Muggy Weather Robotics Duo A C++ System That Thinks, Feels (Sensors!), and Acts Humidity is like the quiet character in the weather story that actually runs the show. On muggy days, everything feels heavier—breathing, drying laundry, running machines, even keeping a data center cool. For people, it’s about comfort and health; for machines, it’s about performance and reliability; for plants and buildings, it’s about moisture balance and mold risk. In robotics and automation, muggy weather isn’t just a nuisance—it’s a signal . It tells your systems when to ventilate, when to dehumidify, when to throttle physically demanding tasks, and when to take preventative maintenance actions. Today, we’ll build a two-program C++ system that “understands” muggy weather: Program A — sensor_hub.cpp A sensor-side program that generates (or ingests) a live stream of environmental data (temperature, relative humidity, pressure, CO₂, VOCs). Think of it as your robotic nose and skin , con...

C++ Secure Chat System

 C++ Secure Chat System

A secure chat system in C++ consists of two programs that work together: one for encrypting and sending messages and the other for decrypting and displaying them.

Main Features

The system includes:

Program A (Sender)

  • Encrypts messages using an algorithm like AES or XOR.
  • Saves encrypted messages to a file.

Program B (Receiver)

  • Reads encrypted messages from the file.
  • Decrypts them using the same encryption method.

Program A: Sender

This program encrypts a message and saves it to a file.

Code:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

// Simple XOR encryption
string encryptMessage(const string& message, char key) {
    string encrypted = message;
    for (char& c : encrypted) {
        c ^= key;
    }
    return encrypted;
}

int main() {
    string message;
    char key = 'X'; // Secret key

    cout << "Enter message to encrypt: ";
    getline(cin, message);

    string encryptedMessage = encryptMessage(message, key);

    // Save to file
    ofstream outFile("secure_message.txt");
    if (outFile) {
        outFile << encryptedMessage;
        outFile.close();
        cout << "Message encrypted and saved.\n";
    } else {
        cout << "Error saving message!\n";
    }

    return 0;
}

Program B: Receiver

This program reads an encrypted message from the file and decrypts it.

Code:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

// Simple XOR decryption (same as encryption)
string decryptMessage(const string& encryptedMessage, char key) {
    string decrypted = encryptedMessage;
    for (char& c : decrypted) {
        c ^= key;
    }
    return decrypted;
}

int main() {
    string encryptedMessage;
    char key = 'X'; // Same secret key

    // Read from file
    ifstream inFile("secure_message.txt");
    if (inFile) {
        getline(inFile, encryptedMessage);
        inFile.close();

        string decryptedMessage = decryptMessage(encryptedMessage, key);
        cout << "Decrypted message: " << decryptedMessage << endl;
    } else {
        cout << "Error reading message!\n";
    }

    return 0;
}

How It Works Together

  1. Run Program A (Sender):

    • Enter a message.
    • The message is encrypted and saved to a file.
  2. Run Program B (Receiver):

    • Reads the encrypted message from the file.
    • Decrypts it using the same key.
    • Displays the original message.

This simple C++ secure chat system demonstrates basic encryption and decryption using XOR. For stronger security, AES or other cryptographic algorithms should be considered.

Comments

Popular posts from this blog

C++ Projects: Basic Traffic Management System

C++ Projects: Book Shop Management System

🌿 Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms"