KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > softabar > sha4j > Sha384


1 /*
2  * Copyright (C) 2006 Softabar
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the
16  * Free Software Foundation, * Inc., * 59 Temple Place, * Suite 330,
17  * Boston, MA 02111-1307 USA
18 */

19 package com.softabar.sha4j;
20
21 import java.io.File JavaDoc;
22
23
24 /**
25  * Usage: java com.softabar.sha4j.Sha384 <text> or Sha384 -f<filename>. <br/>
26  * Calculates SHA-384 from text or file.
27  *
28  * <pre>
29  * Copyright (C) 2006 Softabar
30  *
31  * This program is free software; you can redistribute it and/or modify it
32  * under the terms of the GNU General Public License as published by the
33  * Free Software Foundation; either version 2 of the License, or
34  * (at your option) any later version.
35  *
36  * This program is distributed in the hope that it will be useful, but
37  * WITHOUT ANY WARRANTY; without even the implied warranty of
38  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39  * GNU General Public License for more details.
40  *
41  * You should have received a copy of the GNU General Public License
42  * along with this program; if not, write to the
43  * Free Software Foundation, * Inc., * 59 Temple Place, * Suite 330,
44  * Boston, MA 02111-1307 USA
45  * </pre>
46  *
47  * @version 1.0
48 */

49 public class Sha384
50 {
51   
52   public static void main(String JavaDoc[] args)
53   {
54     try
55     {
56       String JavaDoc text=args[0];
57       if(text==null)
58       {
59         System.out.println("Usage: Sha384 <text> or Sha384 -f<filename>");
60         return;
61       }
62       if(text.startsWith("-f"))
63       {
64         System.out.println(ShaUtil.toSha384String(new File JavaDoc(text.substring(2))));
65         
66       }
67       else
68       {
69         System.out.println(ShaUtil.toSha384String(text));
70       }
71     }
72     catch(Exception JavaDoc e)
73     {
74       System.out.println(e.toString());
75       System.out.println("Usage: Sha384 <text> or Sha384 -f<filename>");
76     }
77
78   }
79
80 }
81
Popular Tags