Page 1 of 1

## Cryptography Fundamentals of Cryptography In Java! Rate Topic: 2 Votes //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=88150&amp;s=3a4b39a13b5423680db4dc30a1c33724&md5check=' + ipb.vars['secure_hash'], cur_rating: 4, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 tanah.melayu

Reputation: 5
• Posts: 45
• Joined: 21-February 09

Posted 21 February 2009 - 12:29 PM

This tutorial is actually a response to a tutorial written by William Wilson about Steganography. It is better for you to apply both Cryptography and Steganography so that you'll get a better protection for your data. Wilson wrote a great explaination about the different between both terms. However, I will explain it again to help you understanding this topic only by viewing this page.

Cryptography & Steganography?
1. Cryptography is a method which contains techniques for you to transform a data in order to hide the original message of the data from being understand by an unauthorised user.
2. Steganography is a method which also contains techniques for you to hide a data from being viewed by an unauthorised user.

What Are Differents Between Them?
Nothing beside the use of each of the method. By using cryptography, a data can still be viewed by anyone. However, they can't understand what it's about since you've transformed it into something which the message is far away from the original data. Steganography is on the other hand. The used of it is just to hide a data from being viewed. It doesn't transform the data. It just HIDE!

Cryptography, Cryptology, Cryptanalysis.. What Are They?
The main title for this issue is 'Cryptology'. Cryptology is divided in two which are 'Cryptography' and 'Cryptanalysis'. Cryptology is a method to transform a data while Cryptanalysis is a method to get back the original data.

Introduction to Cryptography

This is a huge topic! It'll take days to write everything about it. The fact is, every techniques in Cryptography written in any books, actually came from only a few basic techniques. Those techniques had been combined and developed with new ideas to get new techniques.In this tutorial, I'll show you how to implement Cryptography in Java programming without using any API or other outsider stuffs.

1# Monoalphabetic Chipers
Monoalphabetic Chipers is a truly basic technique in Cryptography. I ever thought the same idea when i was a kid. The algorithm for this technique is too easy to be break by someone. However, sometimes it's also useful on certain conditions.

This technique works by assigning every each character to other character. For example:

Quote

a = K
b = 3
c = o
d = p
e = R

Once you've created your own map of character, you can implement this technique by using only a Switch Structures. Look at a full sample:

```import java.util.*;
import java.io.*;

public class monoalphabetic_chipers
{
static Scanner console = new Scanner(System.in);

public static void main(String[] args)
throws IOException
{

String plaintext;
int x;

System.out.println("Enter Words To Encrypt");

x = plaintext.length();
char[] chac = new char[x];

for(int i = 0; i < x; i++)
{
chac[i] = plaintext.charAt(i);
}

System.out.print("Chipper: ");

for(int i = 0; i < chac.length; i++)
{
switch(chac[i])
{
case'a':
chac[i] = 'K';
break;
case'b':
chac[i] = '3';
break;
case 'c':
chac[i] = 'o';
break;
case 'd':
chac[i] = 'p';
break;
case 'e':
chac[i] = 'R';
break;
}
System.out.print(chac[i]);
}
}
}
```

#2 ROT13
ROT13 is similar to Monoalphabetic Chippers technique. However, no need for you to build a map of characters. It used an idea which is call 'Keying' where a key is choosed to encrypt data. In ROT13, number '13' is the key for that.

Simply, choose a character. No matter left or right, shift on a side for 13 times. There it is! You'll get character which is on the other side. Since there are 26 characters, number 13 will give us the opposite character. For this technique, you can also simply apply switch structure so that you will not going to be mad for a short code but great algorithm.

Common Basic Things Should We Used
I should write this on the top. To let you know, to implement cryptography in Java, we'll often use BufferedReader, Array and Looping. However, it depends on your algorithm. Usually, they are used several times in an algorithm.

----------------------------
That's all for this tutorial! Don't think this is it... there are many things in Cryptography and this is just the basic. I planned to keep on writing about Polyalphabetic Chipers and a few more basic techniques. I'll do but not now! I need to start a new post for that to make sure you understand every single word I write. If not, everything will become useless. Upcoming tutorial will become much more harder than this. However, once you get the idea; cryptography will work fine for you.

~ tanah melayu ~

Is This A Good Question/Topic? 1

## Replies To: Cryptography

### #2 abgorn

• sudo apt-get install brain

Reputation: 30
• Posts: 1,410
• Joined: 05-June 08

Posted 27 February 2009 - 11:49 AM

Thank you so much, there is now a cryptography tutorial!

### #3 javamama

Reputation: 0
• Posts: 2
• Joined: 23-November 09

Posted 24 November 2009 - 06:18 PM

Thank you.