Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AtbashCipher {
- StringBuilder code = new StringBuilder();
- String inputString = "hello there";
- char chars;
- public String getEingabe() {
- return this.inputString;
- }
- public char getChars() {
- return this.chars;
- }
- public void setChars(char chars) {
- this.chars = chars;
- }
- byte[] charString = inputString.getBytes();
- public char encode(char c) {
- char help = Character.toLowerCase(c);
- String alphabet = "abcdefghijklmnopqrstuvwxyz";
- for (int i = 0; i < alphabet.length(); i++) {
- if (help == alphabet.toLowerCase().charAt(i)) {
- c = alphabet.charAt(26 - i - 1);
- code.append(c);
- System.out.print(c);
- return c;
- }
- }
- System.out.print(c);
- return c;
- }
- public char decode(char c) {
- char help = Character.toLowerCase(c);
- String alphabet = "abcdefghijklmnopqrstuvwxyz";
- for (int i = 0; i < alphabet.length(); i++) {
- if (help == alphabet.toLowerCase().charAt(i)) {
- c = alphabet.toLowerCase().charAt(26 - i - 1);
- code.append(c);
- System.out.print(c);
- return c;
- }
- }
- System.out.print(c);
- return c;
- }
- public static void main(String[] args) {
- AtbashCipher atb = new AtbashCipher();
- for (int j = 0; j < atb.getEingabe().length(); j++) {
- atb.setChars(atb.getEingabe().charAt(j));
- atb.encode(atb.getChars());
- }
- }
- }
- public AtbashWriter(Writer base, AtbashCipher cipher)
- public void write(char[] cbuf, int off, int len)
- public void flush()
- public void close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement