A secure emotion-aware text processing system that combines RSA encryption with AI-powered emotion analysis.
The Emotion Cipher System allows you to:
- Encrypt text messages using RSA-2048 encryption
- Analyze emotions in text using AI (OpenAI GPT-3.5-turbo)
- Interactive processing with real-time user input
- Demonstrate capabilities with predefined examples
- π RSA-2048 Encryption: Secure text encryption with OAEP padding
- π€ AI Emotion Analysis: Powered by OpenAI GPT-3.5-turbo for emotion detection
- π¬ Interactive Mode: Real-time message processing with user input
- π Demo Examples: 5 predefined examples for testing and demonstration
- π Complete Processing Cycle: Encrypt β Analyze β Decrypt with emotion preservation
- Python 3.7 or higher
- OpenAI API key (for emotion analysis features)
-
Clone the repository
git clone https://github.com/muhammadnavas/Emotion-Cipher-System.git cd Emotion-Cipher-System -
Install dependencies
pip install -r requirements.txt
-
Set up OpenAI API Key
Set your OpenAI API key as an environment variable:
set OPENAI_API_KEY=your_openai_api_key_here
Run the main system for real-time message processing:
python emotion_cipher_system.pyThis provides:
- Interactive message input prompts
- Real-time encryption and emotion analysis
- Session tracking and statistics
Run predefined examples to see the system in action:
# Full demo with 5 examples
python demo_hardcoded.py
# Quick single test
python demo_hardcoded.py quick
# Batch processing test
python demo_hardcoded.py batchfrom emotion_cipher_system import EmotionCipherSystem
# Initialize the system
system = EmotionCipherSystem()
# Process a message in PDF format
result = system.pdf_format_demo("I'm excited about this project!")
# Process with custom options
result = system.process_message(
"Hello world!",
analyze_emotion=True,
pdf_format=True
)Input:
"I'm thrilled about this breakthrough!"
Encrypted Output:
Encrypted Text: "a8F2!k9@mP4$nQ7x"
Detected Emotion: Joy + Excitement
Decrypted Output:
Original Message: "I'm thrilled about this breakthrough!"
Detected Emotion: Joy + Excitement
DecodeAI/
βββ emotion_cipher_system.py # Main interactive system
βββ demo_hardcoded.py # Hardcoded examples (5 demos)
βββ rsa_encryption.py # RSA encryption core
βββ openai_integration.py # OpenAI emotion analysis
βββ requirements.txt # Python dependencies
βββ README.md # Documentation
βββ keys/ # RSA key storage (auto-generated)
βββ private_key.pem
βββ public_key.pem
The system includes 5 predefined examples:
- Mixed Emotions: "Feeling ecstatic about joining the new AI research team, though a bit anxious about the deadlines ahead."
- Negative Emotions: "I can't believe I failed that test again. I'm so disappointed and frustrated right now."
- Positive Emotions: "Finally got the job offer! I'm thrilled and can't wait to start this new journey."
- Love & Excitement: "I absolutely love this new technology! It's going to revolutionize everything we do."
- Worry & Stress: "I'm really worried about the presentation tomorrow. What if something goes wrong?"
process_message(message, analyze_emotion=True, pdf_format=False)- Core processingdecrypt_message(encrypted_message, pdf_format=False, detected_emotion=None)- Decrypt with optionsinteractive_demo()- Run interactive session with user inputget_system_status()- Get current system status and capabilities
from emotion_cipher_system import EmotionCipherSystem
system = EmotionCipherSystem()
# PDF format processing
result = system.pdf_format_demo("I'm excited!")
# Check system status
status = system.get_system_status()
print(f"Encryption ready: {status['encryption']['keys_ready']}")
print(f"AI available: {status['emotion_analysis']['available']}")Set your OpenAI API key as an environment variable:
Windows:
set OPENAI_API_KEY=your_openai_api_key_hereLinux/Mac:
export OPENAI_API_KEY=your_openai_api_key_here- With API Key: Full functionality including emotion analysis
- Without API Key: Encryption works, but emotion analysis will show "Unknown"
- Rate Limits: The system handles OpenAI rate limits gracefully
- Auto Key Generation: RSA keys are generated automatically on first run
- RSA-2048 Encryption: Uses cryptographically secure 2048-bit RSA keys
- Local Key Storage: Private keys are generated and stored locally
- Secure Processing: Messages are encrypted before any external API calls
- No Data Retention: Only processed emotions (not raw messages) are sent to OpenAI
- Algorithm: RSA-2048 with OAEP padding
- Key Storage: Local PEM format files
- Security: Military-grade encryption standards
- Performance: Optimized for text processing
- Model: OpenAI GPT-3.5-turbo
- Format: "Primary + Secondary" emotion pairs
- Examples: Joy + Excitement, Sadness + Disappointment
- Accuracy: Contextual emotion understanding
The system includes robust error handling:
- API Limits: Graceful handling of OpenAI rate limits
- Network Issues: Retry logic and fallback behaviors
- File Operations: Safe key generation and storage
- User Input: Validation and sanitization
- Encryption Errors: Clear error messages and recovery
- Python: 3.7+ (tested with 3.10)
- Memory: Minimal (< 50MB typical usage)
- Storage: ~1MB for keys and system files
- Network: Required only for OpenAI emotion analysis
-
Set up the environment:
pip install -r requirements.txt set OPENAI_API_KEY=your_key_here -
Try the interactive mode:
python emotion_cipher_system.py
-
Run the demo examples:
python demo_hardcoded.py
-
Test specific functionality:
python demo_hardcoded.py quick
Common Issues:
- "No module named 'cryptography'": Run
pip install -r requirements.txt - "OpenAI API key not found": Set the OPENAI_API_KEY environment variable
- "Keys directory not found": Keys are auto-generated on first run
- "Rate limit exceeded": Wait a moment and try again (handled gracefully)
Success Indicators:
- RSA keys appear in
keys/directory - Interactive mode prompts for input
- Demo examples show encrypted output
- Emotions are detected (with API key)
π§ Questions? Check the troubleshooting section or verify your setup steps.