1

I want to write a program that decrypts an input string. It selects 0,2,4,6,8 etc. characters from each section of text input and displays it in reverse in the decryption output.

Input: bxoqb swi eymrawn yim
Output: my name is bob

Keep in mind that the program ignores the space symbol, and repeats the loop at the beginning of each word!

I couldn't find anything on the net that isn't based on a more complicated encryption/decryption systems. I'm starting with the simple stuff, first.

edit: Yes, my question is how do I learn how to do this? Or if someone could teach me a technique to decode strings like this?

6
  • That's pretty cool. Is there a question? Commented Nov 5, 2015 at 4:43
  • Well decoding it would just be the reverse of encoding. Commented Nov 5, 2015 at 4:52
  • It selects 0,2,4,6,8 etc. characters from each section of text input And how do you do that? It looks like you've added random characters between the message characters (in reverse). How did you choose those characters? Commented Nov 5, 2015 at 4:53
  • The letters in between were chosen at random, they are not important. Commented Nov 5, 2015 at 5:28
  • Is there some issue with the answers on your other question? It might help reveal more about what your aiming to learn. Commented Nov 5, 2015 at 7:25

2 Answers 2

0

pseudo code:

  1. Split your string based of space and store it in list.
  2. iterate your list, get each string(bxoqb) and now extract characters(bob) as you want and save it
  3. Iterate same list in reverse order.

Hope it helps you to start.

Sign up to request clarification or add additional context in comments.

2 Comments

How do I create a list?
you can refer below link for more information beginnersbook.com/2013/12/java-arraylist
0

The following code is the most straightforward way...

//code starts

    public static void main(String[] args) {
    String str = "bxoqb swi eymrawn yim";
    String ans = decryption(str);
    System.out.println(ans);
}

public static String decryption(String str) {
    String ans = "";
    String[] words = str.split(" ");
    for (String s : words) {
        for (int i = 0; i < s.length(); i += 2) {
            ans = s.charAt(i) + ans;
        }
        ans = " " + ans;
    }
    return ans.trim();
}

//code ends

Hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.