Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. public class AtbashCipher {
  2.  
  3. StringBuilder code = new StringBuilder();
  4. String inputString = "hello there";
  5. char chars;
  6.  
  7. public String getEingabe() {
  8. return this.inputString;
  9. }
  10.  
  11. public char getChars() {
  12. return this.chars;
  13. }
  14.  
  15. public void setChars(char chars) {
  16. this.chars = chars;
  17. }
  18.  
  19. byte[] charString = inputString.getBytes();
  20.  
  21.  
  22.  
  23. public char encode(char c) {
  24. char help = Character.toLowerCase(c);
  25. String alphabet = "abcdefghijklmnopqrstuvwxyz";
  26. for (int i = 0; i < alphabet.length(); i++) {
  27. if (help == alphabet.toLowerCase().charAt(i)) {
  28. c = alphabet.charAt(26 - i - 1);
  29. code.append(c);
  30. System.out.print(c);
  31. return c;
  32. }
  33. }
  34. System.out.print(c);
  35. return c;
  36. }
  37.  
  38. public char decode(char c) {
  39. char help = Character.toLowerCase(c);
  40. String alphabet = "abcdefghijklmnopqrstuvwxyz";
  41. for (int i = 0; i < alphabet.length(); i++) {
  42. if (help == alphabet.toLowerCase().charAt(i)) {
  43. c = alphabet.toLowerCase().charAt(26 - i - 1);
  44. code.append(c);
  45. System.out.print(c);
  46. return c;
  47. }
  48. }
  49. System.out.print(c);
  50. return c;
  51. }
  52.  
  53. public static void main(String[] args) {
  54. AtbashCipher atb = new AtbashCipher();
  55. for (int j = 0; j < atb.getEingabe().length(); j++) {
  56. atb.setChars(atb.getEingabe().charAt(j));
  57. atb.encode(atb.getChars());
  58.  
  59. }
  60.  
  61. }
  62. }
  63.  
  64. public AtbashWriter(Writer base, AtbashCipher cipher)
  65.  
  66. public void write(char[] cbuf, int off, int len)
  67. public void flush()
  68. public void close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement