Created
April 21, 2011 09:28
-
-
Save simekadam/934062 to your computer and use it in GitHub Desktop.
Upravena metoda pro parsovani textu
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 { | |
//if (this.password.equals("RADIO")) { | |
//POKUD JSOU ZNAKY VE DVOJICI STEJNE PRIDAM X | |
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 { | |
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