KickJava   Java API By Example, From Geeks To Geeks.

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


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

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