Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
OTP4U (One Time Pad For You) - MessagesPrinter.java

MessagesPrinter.java

Caricato da: Teutoburgo
Scarica il programma completo

  1. /*
  2.     OTP4U 0.8.2 - One Time Pad for you
  3.     Copyright (C) 2003 Pierre Blanc
  4.     Pierre Blanc: blanc_teutoburgo@yahoo.it
  5.     http://www.teutoburgo.tk
  6.     http://it.geocities.com/teutoburgo
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation; either version 2 of the License, or
  11.     (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program; if not, write to the Free Software
  20.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.     or go to      http://www.gnu.org/copyleft/gpl.html
  22. */
  23.  
  24. package tk.teutoburgo.otp4u.util;
  25.  
  26. /**
  27.  * OTP4U 0.9 - Class MessagesPrinter (used to print the help, warranty, etc. messages)
  28.  * Creation date: (30/08/2002 16.50.29)
  29.  * @author: Pierre Blanc
  30.  */
  31. public class MessagesPrinter
  32. {
  33.         boolean isGUI=false;
  34.         private String stringLog="";
  35.  
  36.         public MessagesPrinter(){
  37.         }
  38.         public MessagesPrinter(boolean isGUI){
  39.                 this.isGUI=isGUI;
  40.         }
  41.  
  42.         public void sPrintLog(String s){
  43.       if (isGUI) stringLog=stringLog+s+"\n";
  44.       else System.out.println(s);
  45.     }
  46.         /**
  47.         * Returns to the GUI application the String of the log messages.
  48.         */
  49.     public String flushLog(){
  50.           String output=stringLog+"\n";
  51.           stringLog="";
  52.       return output;
  53.     }
  54.         public void sCatchException (){
  55.           if (isGUI)
  56.           {
  57.           } else System.exit(-1);
  58.         }
  59.         /*
  60.         * Catches an exception differently if it's within the command-line or
  61.         * the GUI application.
  62.         * @param message The exception message.
  63.         */
  64.         public void sCatchException (String message){
  65.           if (isGUI)
  66.           {
  67.                 stringLog=stringLog+message+"\n";
  68.           } else System.exit(-1);
  69.         }
  70.         public void printCopyright(){
  71.                 sPrintLog("OTP4U 0.8.2 Copyright (C) Pierre Blanc 2003"+
  72.           "   http://www.teutoburgo.tk");
  73.         sPrintLog("This software is under"+
  74.           " the GNU GPL license v.2");
  75.     }
  76.     public void printNoWarranty(){
  77.       sPrintLog("\n   BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n"+
  78. "FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\n"+
  79. "OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n"+
  80. "PROVIDE THE PROGRAM 'AS IS' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n"+
  81. "OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n"+
  82. "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\n"+
  83. "TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\n"+
  84. "PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n"+
  85. "REPAIR OR CORRECTION.\n\n"+
  86.  
  87.   " IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n"+
  88. "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n"+
  89. "REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n"+
  90. "INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n"+
  91. "OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n"+
  92. "TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n"+
  93. "YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n"+
  94. "PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n"+
  95. "POSSIBILITY OF SUCH DAMAGES.");
  96.     }
  97.         public void printHelpGUI(){
  98.         sPrintLog("\nThere's a short tutorial in the readme.txt file");
  99.         sPrintLog("Use the Encipher/Decipher buttons to operate on the selected file");
  100.         sPrintLog("The first time you need to generate K4K0 (see the Configure tab)");
  101.         sPrintLog("Use relative names if your files are in the otp4u/plaintexts or ciphertexts directories");
  102.         sPrintLog("Either you can choose every file pressing the 'File' button");
  103.         sPrintLog("You can use multiple configuration files:");
  104.         sPrintLog("to select another, type its name (it has to be in the"+
  105.         " otp4u/config direcory) or press 'Select configuration'");
  106.         sPrintLog("If your key isn't large enough, simply press 'New entropy -> Public'");
  107.         sPrintLog("If you need to retrieve the private key (key4message.rnd) from the public key press 'Random'");
  108.         sPrintLog("You can change its size either from the textfield or from the config file.");
  109.         sPrintLog("For mixed mode refer to the readme.txt file.");
  110.         sPrintLog("For more detailed help refer to the OTP4U manual in the OTP4U/doc directory.");
  111.         }
  112.         public void printLicenseGUI(){
  113.         sPrintLog("OTP4U comes with ABSOLUTELY NO WARRANTY; for details: Help->Warranty");
  114.         sPrintLog("This is free software, and you are welcome to redistribute it"+
  115.         " under certain\nconditions; for details see the gpl.txt file in the otp4u/doc directory.");
  116.         }
  117.  
  118.     public void printHelp() {
  119.         sPrintLog("OTP4U comes with ABSOLUTELY NO WARRANTY; for details: otp4uwin w");
  120.         sPrintLog("This is free software, and you are welcome to redistribute it"+
  121.         " under certain\nconditions; for details see the gpl.txt file.");
  122.         sPrintLog("Usage (under Unix type otp4ux instead of otp4uwin):\n");
  123.         sPrintLog("otp4uwin option [parameter]");
  124.         sPrintLog("");
  125.         sPrintLog("Options:");
  126.         sPrintLog("e : performs encryption (parameter: the filename to write)");
  127.         sPrintLog("d : performs decryption (parameter: the filename to write)");
  128.         sPrintLog("g : generates a pseudo-random file as entropy source"+
  129.                 "\n    (parameter: the file length in KB)");
  130.         sPrintLog("gk4k0 : generates key4key for the first iteration (PRNG used)");
  131.         sPrintLog("p : generates 'publicKey', key4message and key4key for next iteration");
  132.         sPrintLog("r : from a 'publicKey', creates key4message and key4key for next iteration");
  133.         sPrintLog("If no filename is specified the default file is used.");
  134.         sPrintLog("If you type only the filename OTP4U will search the file in plain/ciphertexts");
  135.         sPrintLog("");
  136.         sPrintLog("Examples: otp4uwin e supersecret.txt");
  137.         sPrintLog("Encrypts the file specified and writes it in the ciphertexts directory");
  138.         sPrintLog("          otp4uwin d supersecret.txt");
  139.         sPrintLog("Decrypts the file specified and writes it in the plaintexts directory");
  140.     sPrintLog("\nSee the readme.txt , doc/algoritm.html , doc/help.html "+
  141.                           ", doc/gpl.txt for more\ninformations.");
  142.         sPrintLog("OTP4U 0.9.2 Copyright (C) Pierre Blanc 2003"+
  143.           "   http://www.teutoburgo.tk");
  144.  
  145.     }
  146.  
  147.  
  148. }