KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > cli > EncryptPwd


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.ui.cli;
15
16 import java.io.BufferedReader JavaDoc;
17 import java.io.InputStreamReader JavaDoc;
18
19 import org.ejbca.util.CertTools;
20 import org.ejbca.util.StringTools;
21
22 /**
23  * Implements the password encryption mechanism
24  *
25  * @version $Id: EncryptPwd.java,v 1.1 2006/08/05 09:59:38 anatom Exp $
26  */

27 public class EncryptPwd extends BaseCommand {
28     /**
29      * main class
30      *
31      * @param args command line arguments
32      */

33     public static void main(String JavaDoc[] args) {
34         try {
35             System.out.println("Please not that this encryption does not provide absolute security, it uses a build in key for encryption to keep the password from at least accidentaly beeing known.");
36             System.out.println("Enter word to encrypt: ");
37             InputStreamReader JavaDoc isr = new InputStreamReader JavaDoc ( System.in );
38             BufferedReader JavaDoc br = new BufferedReader JavaDoc ( isr );
39             String JavaDoc s = br.readLine();
40             CertTools.installBCProvider();
41             System.out.println("Encrypting pwd '"+s+"'");
42             String JavaDoc enc = StringTools.pbeEncryptStringWithSha256Aes192(s);
43             System.out.println(enc);
44         } catch (Exception JavaDoc e) {
45             System.out.println(e.getMessage());
46             //e.printStackTrace();
47
System.exit(-1);
48         }
49     }
50 }
51
Popular Tags