I've designed my own cryptography and made a java app to translate it from english to some weird stuff, and from weird stuff to english. Or any language really.
here is the code:
It only handles lower-case letters noting more nothing less. There is also a limit to how long your word can be, that limit depends on your word. It also doesn't handle sentences, only words.
Here is how it works:
The first letter you translate is always the same letter (a = a, b = b, c = c etc.)
The second letter you translate is shifted one (a = b, b = c, c = d etc.)
The third letter you tanslate is shifted twice (a = c, b = d, c = e etc.)
etc.
Let's say we want to translate "ore".
The first letter always is the same, so we've got this so far: "o.."
The second letter is shifted one to the right, the r becomes s: "os."
The third letter is shifted twice, the e becomes g: "osg"
There you go ore would be osg.
-David
here is the code:
Code:
package cryptography;
import java.util.Scanner;
public class Cryptography {
private static int shift = 0;
private static final char[] alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
private static final Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("1. from Enlish to cryptography");
System.out.println("2. from cryptography to English");
String choicestr = scan.nextLine();
int choiceint = Integer.parseInt(choicestr);
if(choiceint == 1){
String rawui = scan.nextLine();
char[] ui = rawui.toCharArray();
for(int i = 0; i < ui.length; i++){
int number = getNumber(ui[i]) + shift;
System.out.print(getLetter(number));
shift++;
}
} else {
String rawui = scan.nextLine();
char[] ui = rawui.toCharArray();
for(int i = 0; i < ui.length; i++){
int number = getNumber(ui[i]);
number = number - i;
System.out.print(getLetter(number));
shift++;
}
System.out.println();
}
}
private static int getNumber(char letter) {
for(int i = 0; i < 26; i++) {
if(alphabet[i] == letter) {
return i;
}
}
return 0;
}
private static String getLetter(int number) {
return "" + alphabet[number];
}
}
It only handles lower-case letters noting more nothing less. There is also a limit to how long your word can be, that limit depends on your word. It also doesn't handle sentences, only words.
Here is how it works:
The first letter you translate is always the same letter (a = a, b = b, c = c etc.)
The second letter you translate is shifted one (a = b, b = c, c = d etc.)
The third letter you tanslate is shifted twice (a = c, b = d, c = e etc.)
etc.
Let's say we want to translate "ore".
The first letter always is the same, so we've got this so far: "o.."
The second letter is shifted one to the right, the r becomes s: "os."
The third letter is shifted twice, the e becomes g: "osg"
There you go ore would be osg.
-David