Created
April 21, 2011 09:08
-
-
Save simekadam/934030 to your computer and use it in GitHub Desktop.
Metoda pro rozparsovani textu pred encryptaci
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
void prepareStringToEncrypt() { | |
this.pairsToEncrypt = new HashMap<Integer, String>(); | |
String alterTextToEncrypt = this.textToEncrypt.replaceAll(" ", ""); | |
alterTextToEncrypt = Normalizer.normalize(alterTextToEncrypt, Form.NFD).replaceAll("[^\\p{ASCII}]", ""); | |
alterTextToEncrypt = alterTextToEncrypt.replaceAll("[^A-Z]", ""); | |
//System.out.println( "e "+this.password+" "+alterTextToEncrypt); | |
int increment = 0; | |
int index = 0; | |
if (alterTextToEncrypt.length() % 2 != 0) { | |
alterTextToEncrypt = alterTextToEncrypt.concat("X"); | |
} | |
for (char ch : alterTextToEncrypt.toCharArray()) { | |
if (increment % 2 == 0) { | |
this.pair = String.valueOf(ch); | |
increment++; | |
} else { | |
//ZDE POKUD JE KLIC RADIO, TAK PRI ROVNOSTI PO SOBE JDOUCICH DVOU ZNAKU PRIDAM X | |
if (this.password.equals("RADIO")) { | |
if (String.valueOf(ch).equals(this.pair)) { | |
this.pair += getFiller(); | |
increment++; | |
this.pairsToEncrypt.put(index++, this.pair); | |
this.pair = String.valueOf(ch); | |
increment++; | |
} else { | |
this.pair += String.valueOf(ch); | |
//System.out.print(pair+" "); | |
this.pairsToEncrypt.put(index++, this.pair); | |
increment++; | |
} | |
} else { | |
//STANDARDNI PRIPAD, ZDE NEPRIDAVAM X MEZI STEJNE ZNAKY VE DVOJICI | |
this.pair += String.valueOf(ch); | |
//System.out.print(pair+" "); | |
this.pairsToEncrypt.put(index++, this.pair); | |
increment++; | |
} | |
} | |
if (alterTextToEncrypt.length() % 2 != 0) { | |
alterTextToEncrypt = alterTextToEncrypt.concat("X"); | |
} | |
} | |
//System.out.println(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment