MediCrypt

MediCrypt - Secure Medical Image Encryption & Management

MediCrypt is a Next.js web application designed for secure medical image encryption, decryption, and management. It provides features for user authentication with local key files, pixel scrambling based on a Rubik’s cube-inspired algorithm, SM4-like key generation, and an admin dashboard for user oversight.

Features

1. User Authentication & Management

2. Medical Image Encryption

3. Medical Image Decryption

4. Admin Dashboard

Technologies Used

Setup and Installation

  1. Clone the repository:
    git clone <repository-url>
    cd medicrypt-app
    
  2. Install dependencies:
    npm install
    # or
    yarn install
    # or
    pnpm install
    
  3. Set up Environment Variables (for EmailJS): Create a .env.local file in the root of your project and add your EmailJS credentials. If you don’t have them, you can sign up at EmailJS.
    NEXT_PUBLIC_EMAILJS_SERVICE_ID=YOUR_EMAILJS_SERVICE_ID
    NEXT_PUBLIC_EMAILJS_TEMPLATE_ID=YOUR_EMAILJS_TEMPLATE_ID
    NEXT_PUBLIC_EMAILJS_PUBLIC_KEY=YOUR_EMAILJS_PUBLIC_KEY
    
    • NEXT_PUBLIC_EMAILJS_SERVICE_ID: Your EmailJS service ID.
    • NEXT_PUBLIC_EMAILJS_TEMPLATE_ID: The ID of the email template you create in EmailJS. This template should accept variables like to_email, file_name, decryption_key, and user_email.
    • NEXT_PUBLIC_EMAILJS_PUBLIC_KEY: Your EmailJS Public Key (User ID).

    Note: If EmailJS variables are not set or are set to placeholder values, the email notification feature will be disabled, and a warning will be shown in the UI.

  4. (Optional) Genkit Setup (if using GenAI features - not core to current functionality but Genkit files are present): If you plan to extend with Genkit AI features:
    • Ensure you have a Google AI API Key if using the googleAI plugin.
    • Set GOOGLE_GENAI_API_KEY=YOUR_API_KEY in your .env.local file.

Running the Application

  1. Development Mode:
    npm run dev
    

    This will start the Next.js development server, usually on http://localhost:9002.

  2. Build for Production:
    npm run build
    
  3. Start Production Server:
    npm run start
    

How to Use

1. Registration

2. Login

3. Encrypting an Image (User or Admin in Encrypt/Decrypt Tool)

4. Decrypting an Image (User or Admin in Encrypt/Decrypt Tool)

5. Admin Dashboard (Admin Role Only)

6. Logout

Security Notes

Environment Variables for EmailJS

For the “send key via email” feature to work, you need to configure EmailJS:

  1. Sign up/log in at EmailJS.
  2. Add an Email Service (e.g., Gmail).
  3. Create an Email Template. Your template should include placeholders for:
    • Recipient’s email: ``
    • Filename: ``
    • Decryption key: ``
    • Sender’s/User’s email (optional, for context): Example template body: ` Hello,

    The decryption key for your file “” is:

    Please keep this key secure.

    Regards, MediCrypt System (Sent from: ) ```

  4. Find your Service ID, Template ID, and Public Key (User ID) from your EmailJS dashboard.
  5. Create a .env.local file in the project root and add these values:
    NEXT_PUBLIC_EMAILJS_SERVICE_ID=YOUR_SERVICE_ID
    NEXT_PUBLIC_EMAILJS_TEMPLATE_ID=YOUR_TEMPLATE_ID
    NEXT_PUBLIC_EMAILJS_PUBLIC_KEY=YOUR_PUBLIC_KEY
    

If these variables are not set correctly, the email feature will be disabled.


This README provides a comprehensive overview of the MediCrypt application. Remember that many aspects are simplified for demonstration and would require robust, secure implementations for production use.