Skip to content

This Java command-line application analyzes a range of integers to identify specific number theory properties and applies a custom bitwise encryption algorithm. The program is a practical exercise in algorithmic thinking, number theory, and low-level bit manipulation.

Notifications You must be signed in to change notification settings

haidarimahdi/Number_Properties_And_Encryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Assignment 2: Number Properties & Bitwise Encryption

This Java command-line application analyzes a range of integers to identify specific number theory properties and applies a custom bitwise encryption algorithm. The program is a practical exercise in algorithmic thinking, number theory, and low-level bit manipulation.

Core Features

The application iterates through a predefined numerical range and performs the following tasks:

  • Number Theory Analysis: It filters for prime numbers and negative numbers and then checks them for two unique properties:

    • Emirp Numbers: A prime number that results in a different prime number when its decimal digits are reversed (e.g., 13 is prime, and its reverse, 31, is also prime).
    • Twin Primes: A prime number p where either p-2 or p+2 is also a prime number (e.g., 17 is a twin prime because 19 is also prime).
  • Custom Bitwise Encryption: The program implements a custom encryption scheme that demonstrates a deep understanding of bit manipulation.

    • It takes a 32-bit integer and breaks it into four separate 8-bit chunks (bytes).
    • Each 8-bit chunk is then individually encrypted using a bitwise XOR (^) operation with a provided 8-bit key.
    • The four encrypted chunks are then reassembled into the final 32-bit integer.
  • Formatted Console Output: The results are printed to the console in a clean, aligned table, showcasing the identified properties and the encrypted value alongside its custom-formatted binary representation.

Skills & Concepts Demonstrated

This project showcases several key programming and computer science concepts:

  • Number Theory: Implementation of algorithms for primality testing, number reversal, Emirps, and Twin Primes.
  • Bit Manipulation: A strong understanding of low-level data operations, including XOR encryption, bitmasking (&), and bit shifting (<<, >>>).
  • Algorithmic Thinking: Designing clear, procedural solutions for each of the program's distinct tasks.
  • Procedural Programming: The code is well-organized into a collection of static methods, each with a single, clear responsibility.
  • Formatted I/O: Effective use of printf to produce readable and well-structured command-line output.

How to Compile and Run

To run this application, you will need a Java Development Kit (JDK) installed.

  1. Navigate to the src directory from your terminal:

    cd Number_Properties_And_Encryption/src
  2. Compile the Java source file:

    javac ueb/Main.java
  3. Execute the program. Note that all parameters (start, end, key) are currently hard-coded as constants within main():

    java ueb.Main

The program will then execute and print the formatted analysis of the numbers in the specified range directly to your console.

About

This Java command-line application analyzes a range of integers to identify specific number theory properties and applies a custom bitwise encryption algorithm. The program is a practical exercise in algorithmic thinking, number theory, and low-level bit manipulation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages