Created
August 1, 2013 19:02
-
-
Save dhust/6134208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Cipher { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
String plaintext = "Oh say can you see"; | |
String ciphertext = ""; | |
String key = "shift"; | |
//String alphabet = "abcdefghijklmnopqrstuvwxyz"; | |
if (key == "shift") { | |
//newAlphabet = "bcdefghijklmnopqrstuvwxyza"; | |
} | |
for (int i = 0; plaintext.length() > i; i++) { | |
char character = plaintext.charAt(i); | |
int ascii = (int) character; | |
// Shift +1 | |
int newAscii = ascii+1; | |
char newCharacter = (char) newAscii; | |
// Create ciphertext using the shifted character | |
ciphertext += newCharacter; | |
} | |
System.out.println(ciphertext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment