1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100
101 102 103 104 105 106 107 108 109 110
111 112 113 114 115 116 117 118 119 120
121 122 123 124 125 126 127 128 129 130
131 132 133 134 135 136 137 138 139 140
141 142 143 144 145 146 147 148 149 150
151 152 153 154 155 156 157 158 159 160
161 162 163 164 165 166 167 168 169 170
171 172 173 174 175 176 177 178 179 180
181 182 183 184 185 186 187 188 189 190
191 192 193 194 195 196 197 198 199 200
201 202 203 204 205 206 207 208 209 210
211 212 213 214 215 216 217 218 219 220
221 222 223 224 225 226 227 228 229 230
231 232 233 234 235 236 237 238 239 240
241 242 243 244 245 246 247 248 249 250
251 252 253 254 255 256 257 258 259 260
261 262 263 264 265 266 267 268 269 270
271 272 273 274 275 276 277 278 279 280
281 282 283 284 285 286 287 288 289 290
291 292 293 294 295 296 297 298 299 300
301 302 303 304 305 306 307 308 309 310
|
/*
JaVi v0.6 - JavaVigenere - A Java implementation of the Vigenere
cryptographical algorithm
Un'implementazione Java dell'algoritmo di
Vigenere per la crittografia
Copyright (C) 2002 Pierre Blanc
Pierre Blanc: pierre@trek.eu.org , teutoburgo@yahoo.it
http://it.geocities.com/teutoburgo
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or go to http://www.gnu.org/copyleft/gpl.html
Questo programma è software libero; è lecito redistribuirlo o
modificarlo secondo i termini della Licenza Pubblica Generica GNU
come è pubblicata dalla Free Software Foundation, o la versione 2
della licenza.
Questo programma è distribuito nella speranza che sia utile, ma
SENZA ALCUNA GARANZIA; senza neppure la garanzia implicita di
NEGOZIABILITĄ o di APPLICABILITĄ PER UN PARTICOLARE SCOPO. Si
veda la Licenza Pubblica Generica GNU per avere maggiori dettagli.
Questo programma deve essere distribuito assieme ad una copia
della Licenza Pubblica Generica GNU; in caso contrario, se ne può
ottenere una scrivendo alla Free Software Foundation, Inc., 59
Temple Place, Suite 330, Boston, MA 02111-1307 USA oppure da
http://www.gnu.org/copyleft/gpl.html
Un grazie sentito a Roberto detto "Piano Man" per l'importante aiuto.
*/
package JaVi;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Javi2Applet extends Applet {
boolean isTAKEditable = false;
boolean isTAKVisible = true;
boolean isStandalone = false;
Vigenere vi=new Vigenere();
BorderLayout borderLayout1 = new BorderLayout();
Panel panelLanguage = new Panel();
GridLayout gridLayout3 = new GridLayout(3,1);
Button buttonEnglish = new Button();
Button buttonItaliano = new Button();
Panel panel1 = new Panel();
GridLayout gridLayout1 = new GridLayout(3,1);
Panel panelPhrase = new Panel();
Panel panelKey = new Panel();
Panel panelEncrypted = new Panel();
FlowLayout flowLayout1 = new FlowLayout();
Label labelPhrase = new Label();
TextArea textArea1 = new TextArea("Insert your phrase here",3,30,
TextArea.SCROLLBARS_VERTICAL_ONLY);
FlowLayout flowLayout2 = new FlowLayout();
Button buttonCrypt = new Button();
Label labelKey = new Label();
TextArea textAreaKey = new TextArea("Key",3,30,
TextArea.SCROLLBARS_VERTICAL_ONLY);
Button buttonDecrypt = new Button();
FlowLayout flowLayout3 = new FlowLayout();
Label labelEncrypted = new Label();
TextArea textArea3 = new TextArea("Encrypted",3,30,
TextArea.SCROLLBARS_VERTICAL_ONLY);
Panel panelCheck = new Panel();
Panel panelEditable = new Panel();
Panel panelVisible = new Panel();
FlowLayout flowLayout4 = new FlowLayout();
Checkbox checkbox1 = new Checkbox("CBVisible", isTAKVisible);
FlowLayout flowLayout5 = new FlowLayout();
Checkbox checkbox2 = new Checkbox("CBEditable", isTAKEditable);
FlowLayout flowLayout6 = new FlowLayout();
Button buttonReset = new Button();
Panel panelAbout = new Panel();
GridLayout gridLayout2 = new GridLayout(3,1);
Label label1 = new Label();
Label label3 = new Label();
Panel panel2 = new Panel();
FlowLayout flowLayout7 = new FlowLayout();
Label label2 = new Label();
Label label4 = new Label();
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public Javi2Applet() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
this.resize(500,340);
this.setLayout(borderLayout1);
panelLanguage.setLayout(gridLayout3);
buttonEnglish.setBackground(new Color(0, 192, 138));
buttonEnglish.setLabel("English");
buttonEnglish.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
buttonEnglish_mouseClicked(e);
}
});
buttonItaliano.setBackground(new Color(255, 138, 0));
buttonItaliano.setForeground(Color.white);
buttonItaliano.setLabel("Italiano");
buttonItaliano.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(MouseEvent e) {
buttonItaliano_mousePressed(e);
}
});
panelLanguage.setBackground(Color.gray);
panel1.setBackground(Color.blue);
panel1.setLayout(gridLayout1);
panelPhrase.setLayout(flowLayout1);
labelPhrase.setForeground(Color.yellow);
panelKey.setLayout(flowLayout2);
buttonCrypt.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
buttonCrypt_mouseClicked(e);
}
});
textAreaKey.setText(Double.toString(java.lang.Math.PI)+
Double.toString(java.lang.Math.E));
textAreaKey.setBackground(Color.lightGray);
textAreaKey.setEditable(isTAKEditable);
textAreaKey.setVisible(isTAKVisible);
buttonDecrypt.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
buttonDecrypt_mouseClicked(e);
}
});
panelEncrypted.setLayout(flowLayout3);
labelEncrypted.setForeground(Color.yellow);
textArea3.setBackground(Color.blue);
textArea3.setForeground(Color.yellow);
textArea3.setText("");
panelCheck.setLayout(flowLayout6);
panelVisible.setLayout(flowLayout4);
checkbox1.setBackground(SystemColor.text);
checkbox1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(MouseEvent e) {
checkbox1_mousePressed(e);
}
});
panelEditable.setLayout(flowLayout5);
checkbox2.setBackground(SystemColor.text);
checkbox2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(MouseEvent e) {
checkbox2_mousePressed(e);
}
});
panelKey.setBackground(Color.pink);
panelCheck.setBackground(Color.gray);
panelVisible.setBackground(Color.gray);
panelEditable.setBackground(Color.gray);
panelPhrase.setBackground(SystemColor.desktop);
panelEncrypted.setBackground(SystemColor.desktop);
buttonReset.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
buttonReset_mouseClicked(e);
}
});
textArea1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
textArea1_mouseClicked(e);
}
});
textArea1.setBackground(Color.blue);
textArea1.setForeground(Color.yellow);
panelAbout.setLayout(gridLayout2);
label3.setText("Copyright (C) P.Blanc 2002 - teutoburgo@yahoo.it - "+
"pierre@trek.eu.org");
this.setBackground(SystemColor.text);
panel2.setLayout(flowLayout7);
label2.setText("b<AE=<");
englishVersion();
this.add(panelLanguage, BorderLayout.EAST);
panelLanguage.add(buttonEnglish, null);
panelLanguage.add(buttonItaliano, null);
this.add(panel1, BorderLayout.CENTER);
panel1.add(panelPhrase, null);
panelPhrase.add(labelPhrase, null);
panelPhrase.add(textArea1, null);
panel1.add(panelKey, null);
panelKey.add(buttonCrypt, null);
panelKey.add(labelKey, null);
panelKey.add(textAreaKey, null);
panelKey.add(buttonDecrypt, null);
panel1.add(panelEncrypted, null);
panelEncrypted.add(labelEncrypted, null);
panelEncrypted.add(textArea3, null);
this.add(panelCheck, BorderLayout.SOUTH);
panelCheck.add(buttonReset, null);
panelCheck.add(panelVisible, null);
panelVisible.add(checkbox1, null);
panelCheck.add(panelEditable, null);
panelEditable.add(checkbox2, null);
this.add(panelAbout, BorderLayout.NORTH);
panelAbout.add(label1, null);
panelAbout.add(label3, null);
panelAbout.add(panel2, null);
panel2.add(label4, null);
panel2.add(label2, null);
}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
void buttonItaliano_mousePressed(MouseEvent e) {
labelPhrase.setText("Frase");
buttonCrypt.setLabel("Critta");
labelKey.setText("Chiave");
buttonDecrypt.setLabel("Decritta");
labelEncrypted.setText("Frase Crittata");
checkbox1.setLabel("Chiave visibile");
checkbox2.setLabel("Chiave editabile");
buttonReset.setLabel("Resetta Chiave");
textArea1.setText("Inserisci qui la tua frase");
textArea1.selectAll();
label1.setText("JaVi - v0.6 - Un'implementazione Java dell'algoritmo "+
"di Vigenere.");
label4.setText("Questo software e' tutelato dalla GPL license v.2");
}
void checkbox1_mousePressed(MouseEvent e) {
textAreaKey.setVisible(!textAreaKey.isVisible());
}
void checkbox2_mousePressed(MouseEvent e) {
textAreaKey.setEditable(!textAreaKey.isEditable());
}
void textArea1_mouseClicked(MouseEvent e) {
textArea1.selectAll();
}
void buttonCrypt_mouseClicked(MouseEvent e) {
textArea3.setText(vi.getEncryptedPhrase(textArea1.getText(),
textAreaKey.getText()));
textArea1.setText("");
}
void buttonDecrypt_mouseClicked(MouseEvent e) {
textArea1.setText(vi.getPhrase(textArea3.getText(),
textAreaKey.getText()));
}
void buttonEnglish_mouseClicked(MouseEvent e) {
englishVersion();
}
void buttonReset_mouseClicked(MouseEvent e) {
textAreaKey.setText(Double.toString(java.lang.Math.PI)+
Double.toString(java.lang.Math.E));
}
void englishVersion (){
labelPhrase.setText("Phrase");
buttonCrypt.setLabel("Encrypt");
labelKey.setText(" Key ");
buttonDecrypt.setLabel("Decrypt");
labelEncrypted.setText("Encrypted Phrase");
checkbox1.setLabel("Visible Key ");
checkbox2.setLabel("Editable Key ");
buttonReset.setLabel(" Reset Key ");
textArea1.setText("Insert your phrase here");
textArea1.selectAll();
label1.setText("JaVi - v0.6 - A Java implementation of the Vigenere"+
" algorithm.");
label4.setText("This software is under the GPL license v.2 ");
}
}
|