Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > by-pkgid > 0b451ab745aee3258bf7490a17fe59b9 > files > 4

rssowl-1.2.2-3mdv2007.0.src.rpm

--- src/java/net/sourceforge/rssowl/util/CryptoManager.java.orig	2006-04-23 05:30:41.000000000 -0700
+++ src/java/net/sourceforge/rssowl/util/CryptoManager.java	2006-05-06 09:27:30.000000000 -0700
@@ -24,7 +24,9 @@
 
 package net.sourceforge.rssowl.util;
 
-import net.sourceforge.blowfishj.BlowfishEasy;
+import javax.crypto.*;
+import javax.crypto.spec.*;
+
 import net.sourceforge.rssowl.controller.GUI;
 import net.sourceforge.rssowl.util.shop.StringShop;
 
@@ -56,15 +58,28 @@
   /** An instance of the CryptoManager */
   private static CryptoManager instance;
 
-  private BlowfishEasy blowFish;
+  private Cipher bfe;
+  private Cipher bfd;
+
   private Hashtable crypta;
 
   /**
    * Called from the static factory Method
    */
   private CryptoManager() {
-    blowFish = new BlowfishEasy(new char[] { 114, 115, 115, 111, 119, 108, 50, 48, 48, 52, 126 });
-    loadData();
+    try
+      {
+	  bfe = Cipher.getInstance("Blowfish/ECB/PKCS7");
+	  bfd = Cipher.getInstance("Blowfish/ECB/PKCS7");
+	  SecretKeySpec skeyspec = new SecretKeySpec (new byte[] { 114, 115, 115, 111, 119, 108, 50, 48, 48, 52, 126 },
+						      "Blowfish");
+	  bfe.init(Cipher.ENCRYPT_MODE, skeyspec);
+	  bfd.init(Cipher.DECRYPT_MODE, skeyspec);
+	  loadData();
+      }
+    catch (Exception _)
+      {
+      }
   }
 
   /**
@@ -176,9 +191,12 @@
    */
   private void decryptData() {
     Enumeration keys = crypta.keys();
-    while (keys.hasMoreElements()) {
-      String key = (String) keys.nextElement();
-      crypta.put(key, blowFish.decryptString((String) crypta.get(key)));
+    try {
+	while (keys.hasMoreElements()) {
+	    String key = (String) keys.nextElement();
+	    crypta.put(key, new String (bfd.doFinal((byte[]) crypta.get(key))));
+	}
+    } catch (Exception _) {
     }
   }
 
@@ -187,9 +205,12 @@
    */
   private void encryptData() {
     Enumeration keys = crypta.keys();
-    while (keys.hasMoreElements()) {
-      String key = (String) keys.nextElement();
-      crypta.put(key, blowFish.encryptString((String) crypta.get(key)));
+    try {
+	while (keys.hasMoreElements()) {
+	    String key = (String) keys.nextElement();
+	    crypta.put(key, bfe.doFinal(((String) crypta.get(key)).getBytes()));
+	}
+    } catch (Exception _) {
     }
   }