fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int shift = 11;
  13.  
  14. String data = "I can read this IP 192.168.0.1";
  15. System.out.println("Data : " + data);
  16.  
  17. // cipher the data.
  18. char[] chars = data.toCharArray();
  19. for (int i = 0; i < chars.length; ++i) {
  20. chars[i] = (char) (chars[i] + shift);
  21. }
  22.  
  23. String cipher = new String(chars);
  24. System.out.println("Cipher : " + cipher);
  25.  
  26. // decipher the data.
  27. chars = cipher.toCharArray();
  28. for (int i = 0; i < chars.length; ++i) {
  29. chars[i] = (char) (chars[i] - shift);
  30. }
  31.  
  32. String decipher = new String(chars);
  33. System.out.println("Decipher: " + decipher);
  34. }
  35. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
Data    : I can read this IP 192.168.0.1
Cipher  : T+nly+}plo+st~+T[+<D=9<AC9;9<
Decipher: I can read this IP 192.168.0.1