Skip to content

yahya-debug/Crypto_system

Repository files navigation

AI Cipher Breaker

A Java project that breaks classical ciphers using AI-assisted cryptanalysis (Gemini 2.5 Flash API).

Ciphers

Shift (Caesar) Cipher

  • Encryption/Decryption via ShiftCryptoSystem — rotates letters by a fixed key (0–25).
  • Brute-force attack via ShiftCipherBreaker — tries all 26 possible keys, then asks Gemini to pick the readable English result.

Vigenère Cipher

  • Encryption/Decryption via VigenereCipher — uses a repeating keyword to shift each letter.
  • Kasiski examination via KasiskiTest — identifies repeated trigrams in the ciphertext, computes GCDs of their distances to estimate key length, then uses frequency-analysis dot-product scoring to guess each key letter. Finally asks Gemini to confirm readability and reduces the key to its shortest repeating unit.

Usage

Run Driver.java. The menu offers:

1 - Kasiski test (break Vigenère cipher)
2 - Break shift cipher
3 - Exit
  • Kasiski test encrypts a hardcoded plaintext with key "secret", then breaks it and prints the result.
  • Shift breaker prompts for ciphertext and prints all 26 candidates + Gemini's choice.

Files

File Purpose
Driver.java Menu-driven CLI entry point
ShiftCryptoSystem.java Shift cipher encrypt/decrypt/brute-force
ShiftCipherBreaker.java AI-assisted shift cipher breaker
VigenereCipher.java Vigenère encrypt/decrypt
KasiskiTest.java Kasiski examination + frequency analysis + AI confirmation
DotEnv.java .env file loader
FileOperatoins.java File read/write utility
MyObject.java Custom generic hash map

Dependencies

  • Java 11+ (for java.net.http).
  • Internet access — both breakers call the Gemini 2.5 Flash API. Keys are read from .env (see .env.example).

Notes

  • Non-alphabetic characters are preserved by the shift and Vigenère ciphers but stripped by Kasiski analysis.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages