mirror of
https://github.com/Noratrieb/knacken.git
synced 2026-01-14 23:35:00 +01:00
k n a c k e n
This commit is contained in:
parent
f0fd91f97f
commit
b7728a51e7
1 changed files with 2 additions and 2 deletions
|
|
@ -22,14 +22,14 @@ public class Vigenere {
|
|||
private static String encode(String text, String secret) {
|
||||
final String preprocessedText = text.toUpperCase().replaceAll("\\W", "");
|
||||
final String secretRepeat = secret.repeat(text.length() / secret.length() + 1).toUpperCase();
|
||||
final StringBuilder result = new StringBuilder();
|
||||
final StringBuilder result = new StringBuilder(text.length());
|
||||
for (int i = 0; i < preprocessedText.length(); i++) {
|
||||
final char c = preprocessedText.charAt(i);
|
||||
final char s = secretRepeat.charAt(i);
|
||||
|
||||
final char[] cypher = SQUARE[s - 'A'];
|
||||
final char encoded = cypher[c - 'A'];
|
||||
result.append(encoded);
|
||||
result.setCharAt(i, encoded);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue