Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
11 changes: 6 additions & 5 deletions Cipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public String encrypt(String inputString) {
// for all chars in the input string
for (int i = 0; i < inputString.length(); i++)
{

outputString += replaceChar(inputString.charAt(i),true);
}

return outputString;
Expand All @@ -25,9 +25,10 @@ public String decrypt(String inputString) {

// output string will be collected in this variable, one char at a time
String outputString = "";

replaceChar('a',true);

for(int i = 0; i < inputString.length(); i++)
{
outputString += replaceChar(inputString.charAt(i),false);
}
return outputString;
}

Expand All @@ -42,7 +43,7 @@ private char replaceChar(char inputChar, boolean isEncrypt) {
for (int i = 0; i < ORIGINAL_ALPHABET.length(); i++)
{
if(ORIGINAL_ALPHABET.charAt(i) == inputChar) {

return CIPHER_ALPHABET.charAt(i);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions CipherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static void main(String[] args)

String text1_encrypted = cipher.encrypt(text1);
String text1_decrypted = cipher.decrypt(text1_encrypted);


System.out.println("Original Text: " + text1);
System.out.println("Encrypted Text: " + text1_encrypted);
Expand Down