//JulianCodeApplet, copyright 1999 David Faden //for The Gilbert Post, http://www.geocities.com/Athens/Parthenon/ //If you use this code, //please link to The Gilbert Post //and send an e-mail (unencrypted) to gilbertnews@hotmail.com import java.applet.*; import java.net.*; import java.awt.*; public class JulianCodeApplet extends Applet { private static final String ABC="AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890&#@?,.;:*()[]{}_!$%-+="; private static final String ALL_CHAR=ABC+"~^|\\<>/ \'\"\t\r\n"; private TextArea text; private TextField ring; Button ben,bde; private List ad; private URL thegilbertpost=null; private String docBase; private static final String JULIANHEADER="[Decode with JulianCode"; private static final String JULIANCLOSER="[Encoded text ends ABOVE this line.]"; public void init() { try { thegilbertpost=new URL("http://www.geocities.com/Athens/Parthenon/1911/"); } catch(MalformedURLException e2) {thegilbertpost=null;} docBase=getDocumentBase().toString(); if(docBase==null) docBase=""; else docBase=docBase.replace(']',' '); setBackground(Color.white); setLayout(new BorderLayout()); Panel p=new Panel(); p.setLayout(new BorderLayout()); Panel ptop=new Panel(); ptop.add(new Label("Keyword:")); ring=new TextField(10); ring.setEchoCharacter('*'); ptop.add(ring); ptop.add(ben=new Button("Encode")); ptop.add(bde=new Button("Decode")); p.add("North",ptop); p.add("Center",text=new TextArea(35,7)); String premsg=getParameter("init_msg"); if(premsg!=null && premsg.length()>0) text.setText(premsg); ad=new List(1,false); ad.addItem("JulianCodeApplet c1999 The Gilbert Post"); p.add("South",ad); add("Center",p); } public boolean action(Event e,Object arg) { if(e.target==ben) { //Bad practice to do major work in an AWTThread but... encode(); } else if(e.target==bde) decode(); else if(e.target==ad) { getAppletContext().showDocument(thegilbertpost,"_top"); } return true; } //called when page containing applet is hidden //visitor leaving //clear the password/textfields public void stop() { ring.setText(""); text.setText(""); } private void encode() { char[] cring=ring.getText().toCharArray(); //validate the cring if(cring.length<1) return; for(int i=0;i=50) { sb.append('\n'); counter=0; } } return sb.toString(); } //This method will almost certainly go out of the bounds of ALL_CHAR if //the input data has been tampered with...If the input data has been messed up, //it cannot be decrypted anyway. private String fromAlphaNumeric(String s) { StringBuffer sb=new StringBuffer(); char c; int i=-1; try { for(;;) { i++; if(i==s.length()) break; c=s.charAt(i); if(ABC.indexOf(c)==-1); else { if(ABC.indexOf(c)!=(ABC.length()-1)) sb.append(c); else { if(i<(s.length()-1)) i++; else {sb.append(c); break;} c=s.charAt(i); if(ABC.indexOf(c)==-1) {sb.append(ABC.charAt(ABC.length()-1)); continue;} //Assuming we're receiving encoded input; //else this will probably go out of bounds... else sb.append(ALL_CHAR.charAt(ABC.length()-1+ABC.indexOf(c))); } } } } catch(Exception e) {System.out.println(e);} return sb.toString(); } }