01: package com.calipso.reportgenerator.common;
02:
03: import java.net.InetAddress;
04: import java.net.UnknownHostException;
05:
06: /**
07: *
08: * User: jbassino
09: * Date: 31-ago-2005
10: * Time: 10:34:42
11: */
12: public class LocalKeyEncrypter {
13:
14: public static String encrypt(String data) throws Exception {
15: String localKey = getKey();
16: return encrypt(data, localKey);
17: }
18:
19: public static String decrypt(String data) throws Exception {
20: String localKey = getKey();
21: return decrypt(data, localKey);
22: }
23:
24: private static String decrypt(String data, String localKey)
25: throws Exception {
26: Encrypter encrypter = new Encrypter(localKey);
27: return encrypter.decrypt(data);
28: }
29:
30: private static String encrypt(String data, String localKey)
31: throws Exception {
32: Encrypter encrypter = new Encrypter(localKey);
33: return encrypter.encrypt(data);
34: }
35:
36: private static String getKey() {
37: String key = "";
38: try {
39: key += InetAddress.getLocalHost().getHostName();
40: } catch (UnknownHostException e) {
41: //En el caso que no resuelva el nombre de host, no lo sumará a la clave
42: e.printStackTrace();
43: }
44: key += System.getProperty("os.name");
45: key += System.getProperty("os.arch");
46: //System.
47: return key;
48: }
49:
50: }
|