Skip to content

prabhatrm23git/cryptography-x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cryptography Project - Secure Visual Communication System

A MATLAB-based project that implements a secure visual communication system using speech-to-text, AES encryption, BCH error correction coding, and visual data transmission through screen capture.

Overview

This project demonstrates a complete cryptographic communication pipeline where:

  1. Speech input is converted to text
  2. Text is encrypted using AES-256-CBC
  3. Encrypted data is encoded with BCH error correction
  4. Data is visualized as a binary image with green border
  5. Image is transmitted via screen display
  6. Receiver captures screen, decodes, decrypts, and converts back to speech

System Flowchart

System Flowchart

The flowchart illustrates the complete transmitter (TX) and receiver (RX) execution pipeline:

Transmitter Execution (TX)

  1. Speech Input - Voice capture via microphone
  2. Speech to Text - Convert speech to text string
  3. Data Preparation - AES setup and system initialization
  4. Text to Binary - Convert text to binary representation
  5. AES Encryption - Encrypt with AES-256-CBC
  6. BCH Encoding - Add error correction codes
  7. Image Generation - Create binary grid visualization
  8. Padding Data - Fill to required image dimensions
  9. Full Screen Display - Transmit via screen display

Receiver Execution (RX)

  1. Image Capture - Screen capture of transmitted image
  2. Border Detection & Data Extraction - Locate green border and extract data
  3. Binarize - Convert to binary representation
  4. Decode Binary Data - Extract bit stream
  5. BCH Decoding - Error correction and data recovery
  6. AES Decryption - Decrypt to recover original text
  7. Binary to Text - Convert binary to text string
  8. Text to Speech - Convert text to spoken output

Note: The flowchart shows RS encoding/decoding and interleaving steps, but the current implementation skips RS coding to save space and focuses on BCH error correction only.

Features

  • Speech-to-Text: Uses Windows Speech Recognition for voice input
  • AES-256-CBC Encryption: Strong cryptographic protection with PKCS5Padding
  • BCH Error Correction: (63,36) BCH coding for robust transmission
  • Visual Data Transmission: Binary grid visualization with distinctive green border
  • Screen Capture: Automatic detection and capture of transmitted image
  • Text-to-Speech: Python pyttsx3 for cross-platform speech synthesis
  • Error Resilience: Handles transmission errors through BCH coding

Files

  • transmitter_code.m - Transmitter module (encryption + visualization)
  • receiver_code.m - Receiver module (capture + decryption)

System Requirements

  • MATLAB R2022a or later - Main development environment
  • Windows OS - Required for speech recognition APIs
  • Python 3.7+ - Required for pyttsx3 text-to-speech engine
  • Java Runtime Environment - For Java cryptographic operations (AES)
  • Communications Toolbox - For BCH encoder/decoder functions
  • Image Processing Toolbox - For image manipulation and analysis

Dependencies

MATLAB Toolboxes

% Check if required toolboxes are installed
ver('communications')  % Communications Toolbox
ver('image')           % Image Processing Toolbox

Java Components

  • javax.crypto.Cipher - AES encryption/decryption
  • javax.crypto.spec.SecretKeySpec - AES key specification
  • javax.crypto.spec.IvParameterSpec - AES initialization vector
  • java.awt.Robot - Screen capture functionality
  • java.awt.Rectangle - Screen region definition
  • java.awt.GraphicsEnvironment - Graphics environment access

Python Components

  • pyttsx3 - Python text-to-speech engine for cross-platform speech synthesis

.NET Framework Components

  • System.Speech.Recognition.SpeechRecognitionEngine - Speech-to-text
  • System.Speech.Recognition.DictationGrammar - Speech grammar

System Requirements Details

Hardware Requirements

  • Microphone - For speech input capture
  • Speakers/Headphones - For text-to-speech output
  • Display - For visual data transmission (minimum 1024x768 recommended)
  • RAM - Minimum 4GB (8GB recommended for smooth operation)

Software Dependencies

  • Windows Speech Recognition - Must be enabled in Windows settings
  • Python 3.7+ - Required for pyttsx3 text-to-speech engine
  • pyttsx3 - Python text-to-speech library (pip install pyttsx3)
  • Java Cryptography Extension (JCE) - Unlimited strength policy files for AES-256

Installation Commands

% Install additional MATLAB packages (if needed)
% Communications Toolbox
matlab.addons.toolbox.installToolbox('communications')

% Image Processing Toolbox  
matlab.addons.toolbox.installToolbox('image')
# Install Python TTS dependency
pip install pyttsx3

Verification

% Test Java integration
try
    import javax.crypto.Cipher
    disp('✓ Java cryptography available')
catch
    disp('✗ Java cryptography not available')
end

% Test .NET integration
try
    NET.addAssembly('System.Speech')
    disp('✓ .NET Speech available')
catch
    disp('✗ .NET Speech not available')
end

% Test Python TTS integration
try
    [status, result] = system('python -c "import pyttsx3; print(pyttsx3.__version__)"');
    if status == 0
        disp('✓ Python pyttsx3 available')
    else
        disp('✗ Python pyttsx3 not available')
    end
catch
    disp('✗ Python pyttsx3 not available')
end

How It Works

Transmitter (transmitter_code.m)

  1. Speech Input: Captures voice input using Windows Speech Recognition
  2. AES Encryption:
    • Key: 256-bit hexadecimal key
    • IV: 128-bit initialization vector
    • Mode: CBC with PKCS5Padding
  3. BCH Encoding: (63,36) BCH encoder adds error correction
  4. Image Generation: Creates 320x240 binary image with 10x10 blocks
  5. Green Border: Adds distinctive 20px green border for detection
  6. Display: Shows fullscreen for transmission

Receiver (receiver_code.m)

  1. Screen Capture: Captures fullscreen after 20-second delay
  2. Green Border Detection: Identifies transmitted image via green border
  3. Bit Extraction: Samples binary values from grid blocks
  4. BCH Decoding: Corrects transmission errors
  5. AES Decryption: Recovers original plaintext
  6. Text-to-Speech: Converts decrypted text to speech using Python pyttsx3

Usage

Running the Transmitter

run('transmitter_code.m')
  1. Speak clearly when prompted after 2 seconds
  2. The encrypted image will be displayed fullscreen
  3. Keep the window open for transmission

Running the Receiver

run('receiver_code.m')
  1. Start the receiver after transmitter is displaying
  2. Click on the transmitter window when prompted
  3. Wait 20 seconds for automatic capture
  4. Decrypted text will be spoken

Technical Specifications

Cryptographic Parameters

  • AES Key: 211e91dce682d2d514022d9e72a2c013a1c813113326dd290e94dc09da229c72
  • AES IV: 654569dc8be692bbde4f3289fa510610
  • Block Size: 10x10 pixels
  • Image Resolution: 320x240 pixels (24x32 blocks)
  • BCH Code: (63,36) - 27 parity bits per codeword

Color Detection

  • Green Border Threshold: G > 120, R < 100, B < 100
  • Binary Threshold: Otsu's method via graythresh()

Security Considerations

  • The AES key and IV are hardcoded for demonstration purposes
  • In production, use proper key management
  • The green border provides visual identification but no cryptographic security
  • BCH coding provides error correction, not additional security

Error Handling

  • Speech recognition failures prompt retry
  • Green border detection errors halt processing
  • Cryptographic errors are caught and reported
  • Invalid padding or decryption failures are handled gracefully

Performance

  • Transmission Rate: Visual (limited by display refresh)
  • Latency: ~20 seconds (capture delay) + processing time
  • Capacity: 768 bits per frame (24x32 blocks)
  • Error Correction: Up to 27 bit errors per 63-bit codeword

Troubleshooting

  1. Speech Recognition Issues

    • Ensure microphone is working
    • Speak clearly after the 2-second prompt
    • Check Windows Speech Recognition settings
  2. Green Border Not Detected

    • Ensure transmitter window is visible
    • Check display color settings
    • Verify green border is not obscured
  3. Decryption Failures

    • Ensure transmitter and receiver use same key/IV
    • Check for transmission errors
    • Verify BCH decoding success
    • Ensure Python pyttsx3 is properly installed and accessible
  4. Python TTS Issues

    • Verify Python 3.7+ is installed
    • Install pyttsx3: pip install pyttsx3
    • Check Python is in system PATH
    • Test pyttsx3 independently: python -c "import pyttsx3; engine = pyttsx3.init(); engine.say('test'); engine.runAndWait()"

Future Enhancements

  • Dynamic key exchange
  • Multiple frame support for larger messages
  • Adaptive error correction
  • Network-based transmission
  • GUI interface
  • Real-time streaming

License

This project is for educational purposes. Use responsibly and in accordance with applicable laws and regulations.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors