THREAD: [Java] Caesar Cipher
  1. 04-02-2016, 02:58 AM
    primetime43's Avatar
    primetime43
    Knowledge is power Tiphat
    primetime43's Avatar
    primetime43
    Knowledge is power Tiphat
    2,536
    Posts
    38,842
    Reputation
    Jan 2011
    NextGenUpdate
    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.

  2. The Following 5 Users Say Thank You to primetime43 For This Useful Post:

    , , ,

  3. 04-03-2016, 11:55 PM
    John's Avatar
    John
    skid
    John's Avatar
    John
    skid
    1,822
    Posts
    65,814
    Reputation
    Dec 2012
    NextGenUpdate
    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?
  4. 04-04-2016, 03:01 AM
    primetime43's Avatar
    primetime43
    Knowledge is power Tiphat
    primetime43's Avatar
    primetime43
    Knowledge is power Tiphat
    2,536
    Posts
    38,842
    Reputation
    Jan 2011
    NextGenUpdate
    Originally Posted by John View Post

    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.

  5. The Following 2 Users Say Thank You to primetime43 For This Useful Post:

    ,