Post: [Java] Caesar Cipher
04-02-2016, 02:58 AM #1
primetime43
Knowledge is power Tiphat
(adsbygoogle = window.adsbygoogle || []).push({});
Hey there NGU, here I made a tool that uses one of the earliest known uses of encryption. This method of encryption was created by Julius Caesar, who would shift each letter three letters forward in the alphabet (sending the last three letters of the alphabet to the first three). I just made this for fun and thought it was a neat way to show how long encryption has actually been around before computers and how a very simple encryption works. You can take the source code and just copy & paste it to try it out for fun; such as secretly talking to your friend in the shoutbox Cool Troll
You must login or register to view this content.
Also, here is a main to run it if you don't want to write your own.
    
import java.util.Scanner;
public class Test
{
private static Scanner scan = new Scanner(System.in);
public static void main(String[] args)
{
System.out.print("Enter input: ");
String input = scan.nextLine();
CaesarCipher message = new CaesarCipher(input);
message.decrypt();
}
}


Example of how it works:
    
Enter input: Hello members of NGU

Encrypted sentence: KHOOR PHPEHUV RI QJX

Decrypted sentence: HELLO MEMBERS OF NGU

Enjoy! primetime43 Happy
Last edited by primetime43 ; 04-02-2016 at 03:02 AM.

The following 5 users say thank you to primetime43 for this useful post:

Ali, basshead4ever, Kam, Specter
04-03-2016, 11:55 PM #2
Originally posted by primetime43 View Post
Hey there NGU, here I made a tool that uses one of the earliest known uses of encryption. This method of encryption was created by Julius Caesar, who would shift each letter three letters forward in the alphabet (sending the last three letters of the alphabet to the first three). I just made this for fun and thought it was a neat way to show how long encryption has actually been around before computers and how a very simple encryption works. You can take the source code and just copy & paste it to try it out for fun; such as secretly talking to your friend in the shoutbox Cool Troll
You must login or register to view this content.
Also, here is a main to run it if you don't want to write your own.
    
import java.util.Scanner;
public class Test
{
private static Scanner scan = new Scanner(System.in);
public static void main(String[] args)
{
System.out.print("Enter input: ");
String input = scan.nextLine();
CaesarCipher message = new CaesarCipher(input);
message.decrypt();
}
}


Example of how it works:
    
Enter input: Hello members of NGU

Encrypted sentence: KHOOR PHPEHUV RI QJX

Decrypted sentence: HELLO MEMBERS OF NGU

Enjoy! primetime43 Happy


    
private void createMap(char alpha, int value)
{
if(alpha == 'Z'Winky Winky
{
mapAlphabet.put(alpha, value);
mapInteger.put(value, alpha);
return;
}
else
{
mapAlphabet.put(alpha, value);
mapInteger.put(value, alpha);
alpha = (char)(((int)alpha) + 1);
createMap(alpha, value+1);
}
}


This part really bothers me, that "return"
Why's that there?
04-04-2016, 03:01 AM #3
primetime43
Knowledge is power Tiphat
Originally posted by John
    
private void createMap(char alpha, int value)
{
if(alpha == 'Z'Winky Winky
{
mapAlphabet.put(alpha, value);
mapInteger.put(value, alpha);
return;
}
else
{
mapAlphabet.put(alpha, value);
mapInteger.put(value, alpha);
alpha = (char)(((int)alpha) + 1);
createMap(alpha, value+1);
}
}


This part really bothers me, that "return"
Why's that there?


I think I had the recursion a different way at first and then I rewrote it and just forgot to remove that return. :p
I fixed it just for you huehuehue :happyguy:
Last edited by primetime43 ; 04-04-2016 at 05:31 AM.

The following 2 users say thank you to primetime43 for this useful post:

John, Specter

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo