For this tutorial, we will be creating a New Maven Project. To keep thing more simple we will be creating a simple maven project i.e. we will be skipping archetype selection.
New Maven Project Wizard – Creating a simple project
In this tutorial, we will be creating a simple “Hello world” program using Struts 2. For this tutorial we will be using Eclipse, Struts 2. Struts 2 allows you to define configuration either by using traditional Struts 1 like XML way or by using annotations. In this tutorial we will be following traditional XML way. Let’s move ahead! Continue reading Struts 2 Hello World Example (XML Version)→
This Java code demonstrates the core steps of the JPEG compression algorithm. It implements the Discrete Cosine Transform (DCT), quantization, zigzag scan, and a simplified entropy encoding. These are fundamental processes for compressing digital images, reducing file size by transforming and encoding image data.
This example provides an educational look at the key stages of JPEG compression.
Run-Length Encoding (RLE) is a basic form of data compression where consecutive characters (runs) are replaced with a single character followed by the count of repetitions. This simple technique is useful for compressing repetitive data.
This Java program demonstrates how to apply RLE to a line of text input by the user.
A transposition cipher is a method of encryption where the positions of characters are shifted according to a certain system, without changing the actual characters themselves. It rearranges the characters in a message to create ciphertext, and the same method in reverse restores the original message.
This post walks you through how a transposition cipher works using a Java program. This particular example arranges characters into a matrix and reads them column-wise (for encryption) or row-wise (for decryption).
How the Transposition Cipher Works
Encryption:
Fill a matrix column-wise with characters of the message.
Read the characters row-wise to get the encrypted message.
The operation is repeated twice for added confusion.
Decryption:
Reverse the above process by filling the matrix row-wise.
Read it column-wise to retrieve the original message.
In the world of cryptography, RSA (Rivest–Shamir–Adleman) is a popular public-key cryptosystem widely used for secure data transmission. It’s based on the principle that while multiplying large prime numbers is computationally easy, factoring their product is not — which ensures security.
This post will walk you through how RSA encryption and decryption work using a simple Java program. You’ll learn how the sender encrypts a message using the recipient’s public key, and how the receiver decrypts it using their private key.
What Happens Under the Hood?
The RSA algorithm follows these steps:
Key Generation
Choose two large prime numbers p and q.
Compute N = p * q.
Compute the totient function: phi = (p-1)(q-1).
Choose an integer e such that 1 < e < phi and gcd(e, phi) = 1.
Compute d, the modular inverse of e modulo phi.
Encryption
The sender uses the recipient’s public key (e, N) to compute ciphertext: c = m^e mod N.
Decryption
The recipient uses their private key (d, N) to decrypt: m = c^d mod N.