Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void vigin ( int dir ){ //viginaere
- String key = JOptionPane.showInputDialog(
- null,
- "Waehle vigin Verschiebung",
- "ANGELUS");
- String text = textarea.getText();
- char[] cipher = new char [ text.length() ];
- for( int i = 0; i < text.length(); i++){
- char c = text.charAt( i );
- int shift = key.charAt( i % key.length() ) - 'A';
- shift *= dir;
- if( c >= 'A' && c <= 'Z' ){
- c += shift;
- if( c > 'Z'){
- c -= 26;
- } else if( c < 'A' ){
- c += 26;
- }
- }
- cipher[ i ] = c; //not a character
- }//end for
- textarea.setText( new String( cipher ) );
- }
Add Comment
Please, Sign In to add comment