Created
March 22, 2017 04:33
-
-
Save M-ZubairAhmed/626dc070351f7412a7dc72e5ca63281f to your computer and use it in GitHub Desktop.
Algorithm for decrypting improved version of Caesar cypher
This file contains hidden or 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 static String demovingShift(String inputCodedString, int shift, int decremental){ | |
char[] inCodedCharArr = new char[inputCodedString.length()]; | |
for (int q = 0; q < inputCodedString.length(); q++) { | |
int DeFlushV =0 , DeFlushVDec = 0; | |
DeFlushV = (int)inputCodedString.charAt(q); | |
if (DeFlushV >= 65 && DeFlushV <=90){ | |
DeFlushVDec = DeFlushV - shift; | |
if(DeFlushVDec < 65) { | |
while (DeFlushVDec < 65) { | |
DeFlushVDec = 91 - (65 - DeFlushVDec); | |
} | |
inCodedCharArr[q] = (char) DeFlushVDec; | |
} | |
else { | |
inCodedCharArr[q] = (char)DeFlushVDec;}} | |
else if (DeFlushV >= 97 && DeFlushV <=122){ | |
DeFlushVDec = DeFlushV - shift; | |
if(DeFlushVDec < 97) { | |
while (DeFlushVDec < 97) { | |
DeFlushVDec = 123 - (97 - DeFlushVDec); | |
} | |
inCodedCharArr[q] = (char) DeFlushVDec; | |
} | |
else { | |
inCodedCharArr[q] = (char)DeFlushVDec;}} | |
else { | |
inCodedCharArr[q] = inputCodedString.charAt(q);} | |
shift +=decremental; | |
} | |
String decodedString = new String(inCodedCharArr); | |
return decodedString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Decryption of Caesar Improved Cipher with Incremental key
Algorithm decodes the coded text message back to original on the following conditions: